Problem
Consider the following code:
class A
def self.a(b)
if b > 0
b * b
end
end
end
What will be the values of:
var1 = A.a(0)
var2 = A.a(2)
- var1 will be equal to
nil
- var2 will be equal to
4
A conditional statement in Ruby is an expression that returns nil
if the conditional is false
. Ruby methods return the last expression in the method body.