snowscript icon indicating copy to clipboard operation
snowscript copied to clipboard

Implicitly return value maybe?

Open Butjok opened this issue 11 years ago • 2 comments

To be able to write something like:

fn fact(n)
    if n <= 1
        1
        n * fact(n - 1)

Butjok avatar Mar 31 '14 13:03 Butjok

i've been there, and I'm not sure I like it.

vendethiel avatar Mar 31 '14 13:03 vendethiel

This is a functionality present in CoffeeScript, and it can get a bit confusing. For instance, this quite simple to understand:

my_var = if it is 0
   'ok'
else
   'stars'

But for new-comers, this might not be the case (specially for large code blocks):

say_it = (right, now) ->
   as = 'if it'
   (were, real) ->
      if such?.fail is right
         return as + real

      now

I strongly suggest NOT to do it, and never to think about it again. It's nice when you're lazy, and in some cases can improve code readability, but... just, no.

lesmo avatar Mar 18 '15 04:03 lesmo