I want to know if I can create a variable with a boolean as value, something like this:
my_var =
if X > Y
print "The value is true"
else
print "The value is false"
end
This is so I can write a boolean easily.
EDIT:
I'm trying to do "shortcuts" using variables that are equal to a boolean. That way, if I require to write a boolean multiple times in a code, I can just "call" the variable.
Example:
x = gets.chomp
y = gets.chomp
required_boolean =
if x > y
puts "x is greater than y"
elsif x = Y
puts "X and Y are equal"
else
puts "y is greater than x"
end
puts "Since x has a value of #{x} and y has a value of {y}, we can say that #{required_boolean}"
my_var.. it is confusing. Please edit and format the code again correctlymy_var = X > Y(which will betrueorfalse), thenmy_var ? (print "The value is true") : (print "The value is false")orprint "The value is #{my_var ? 'true' : 'false'}".true.to_s == "true", you could run:"The value is #{(my_var = (x > y) ).to_s}"