Ruby if syntax (Two Expressions)

if-statement, ruby, syntax

Solution

if foo == 3: puts "foo"; puts "baz"
elsif foo == 5: puts "foobar"
else puts "bar"
end

However, I advise against it.

Problem

Lets say you are using the `if` syntax for Ruby that goes like this: ``` if foo == 3: puts "foo" elsif foo == 5: puts "foobar" else puts "bar" end ``` Is there a way to do it so Ruby executes two things in the if statement, say, like this: ``` if foo == 3 puts "foo" foo = 1 elsif foo = ... ``` How can I make it so I can put two statements in using the first syntax?

Original source