+ 1
A ruby question
Why there is a keyword "unless" if this keyword do the same things that the keyword "if"? Is this some type of joke from ruby?
2 odpowiedzi
+ 1
No, it's not a joke at all.
In programming there are many different ways to do things.
Why?
Because depending on your situation some ways are better than others.
It's like having the right tool for the job.
Now:
"Until" allows you to phrase your conditionals without having to reverse your condition.
As a result you get easier to read code, which is a good thing!
Example:
if !hot
# do something
end
With "unless":
unless hot
# do something
end