small medium large xlarge

Back to: All Forums  CoffeeScript
Generic-user-small
03 Aug 2011, 01:51
Daniel Fort (3 posts)

I think instead of

doAndRepeatUntil = (condition, body) ->
   body.call this
   body.call this until condition()

there should be this:

doAndRepeatUntil = (condition, body) ->
   loop
     body()
     break if condition()

this way its even more DRY-compliant plus body will be called in @this@ context anyway.

Trevor_burnham__goofy_headshot__pragsmall
30 Jul 2011, 02:36
Trevor Burnham (54 posts)

You’re right, that is a bit more elegant. Though, you got your logic backward: you want to @break if condition()@, not @break unless condition()@.

Generic-user-small
03 Aug 2011, 01:52
Daniel Fort (3 posts)

Oops, sorry. Fixed.

You must be logged in to comment