it's not just one liner. You use return when you want to return from the function early. In fact return doesn't mean to return with a value - that's optional, it just means interrupt this function here.
a
return if b
c
This will return with nil not evaluating c if b.
Otherwise on the last line of the function it's more Ruby-esque not to use return
This is why I love Ruby more than Python!
Absolutely beautiful!
Joli ! Really nice short way to tell a long story
nice one
I knew Ruby could do it in less than 40 characters! Damn!
good to know you can splip up the elements of an array like that.
cool thank you!
This comment is hidden because it contains spoiler information about the solution
can you explain this solutin to me?
if we have a negative (-num) makes it positive and then (abs) should leave it positive
but it's not - why is that?
What about conditions for gandicap? I should be -2 < gandicap < +26. This solution doesn't consider all kata's conditions
Wow, it's fascinating how my 10 to 15 lines of code turns into only just 1 line of code, happened before :)
Good Job.
Me too... Spoilers.... :)
it's not just one liner. You use return when you want to return from the function early. In fact return doesn't mean to return with a value - that's optional, it just means interrupt this function here.
This will return with nil not evaluating
c
ifb
.Otherwise on the last line of the function it's more Ruby-esque not to use return
is it best practice to not explicitly use 'return' for a 1 liner?
Out of specs
Loading more items...