Home If statement operator as a variable in ruby
Reply: 0

If statement operator as a variable in ruby

user306
1#
user306 Published in May 24, 2018, 4:01 pm

I am trying to do something like this in ruby:

x = 0
y = 1
z = "!="

if x #{z} y
  puts "True"
end
#True
#=> nil

x = 1
if x #{z} y
  puts "True"
end
#True
#=> nil

Using a operator as a variable is not evaluating the expression. Any way to do this.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.336834 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO