Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
If you have return, it is an explicit return which can be at any point in a method, but the last expression of any method is always returned as an implicit return, so no return is ever needed for the last expression in a Ruby method.
What do you think happens if a String argument is given? What is supposed to happen?
The if statement is not necessary tho! 😁
You could just write .select{|i| i.digits.sum == x}
Since the two arguments are both booleans we can use them directly when comparing. This solution asks if I'm
employed
and (&&
) not (!
) onvacation
. Since this is Ruby, the last executed line in a method is automatically returned.How in the hell does this work?
I'd like to add that not adding the 'return' is more idiomatic Ruby (& also following the Ruby style guide, see https://rubystyle.guide/#no-explicit-return).
yep, but it's optional
Ruby has an implicit
return
for the last statement in methods.nope, not in ruby
Don't you need to put 'return' in order to use the function properly elsewhere?
This comment is hidden because it contains spoiler information about the solution
Interesting solution! May I ask, how you arrived at this one and why the math adds up the way it does?
Floating point errors ;-)
thx! :) (Note: do not forget the spoiler flag, when you throw bits of code in the comments: they are visible from anyone in their dashboard)
This comment is hidden because it contains spoiler information about the solution
Loading more items...