+ 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?

3rd May 2019, 12:45 PM
Werg Serium
Werg Serium - avatar
2 ответов
3rd May 2019, 12:49 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 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
11th May 2019, 5:53 PM
Jesus Castello
Jesus Castello - avatar