+ 3

This Unless tag in Ruby is somewhat confusing yeah! Can someone check it out?a = 42 unless a < 10 puts "Yes" else puts "no"

The unless statement is used to declare results if the input is lesser or greater than the integer in a conditional way. But in this question, the integer is 42 and the input is lesser than (10) and in this case it is lesser than 42 which will output yes. Somehow confusing yes but it's the correct answer

20th Jun 2018, 7:05 PM
Rex
Rex - avatar
1 ответ
+ 2
unless condition is the same as "if !(condition)" so yea
20th Jun 2018, 8:15 PM
hinanawi
hinanawi - avatar