The _this_ inside process.nextTick seems quite odd to me.. -- Diogo Resende
On Wednesday, June 6, 2012 at 14:31 , Anand George wrote: > Hi! > > Have been reading up on process.nextTick and found this one rather odd. It's > forcing the calling function to run again. > > function addasync(no1, no2, result) > { > res = no1 + no2; > this.result = result(false, res); > process.nextTick(function() { > this.result = result(true, res); > }); > }; > > addasync(1, 2, function(err, res) { > console.log(res); > }); > > function addsync(no1, no2) { > return (no1 + no2); > } > > console.log(addsync(4, 2)); > > When I run this code I get the following output. > > 3 > 6 > 3. > > Any ideas why this could be happening. > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to nodejs@googlegroups.com > (mailto:nodejs@googlegroups.com) > To unsubscribe from this group, send email to > nodejs+unsubscr...@googlegroups.com > (mailto:nodejs+unsubscr...@googlegroups.com) > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en