Ruby lazy if statement without statement
Can this be done in ruby?
variablename = true
if variablename
puts "yes!"
end
Instead of this
variablename = true
if variablename == true
puts "yes!"
end
Edit: also given the presence of:
variablename = 0 #which caused my problem
I cannot get this to work. Is this a style of saying, if possible? I am learning ruby now and it is possible in PHP but I am not sure how to do it in ruby
+3
source to share
3 answers