From: Paul Mckibbin Date: 2011-02-11T00:46:39+09:00 Subject: Re: Ruby ternary operator Sam T. wrote in post #980819: > If I do the following: > > value="off" > p value == "on" ? "YES" : "NO" > p value > > Then I get the >>> "NO", "off" > > Does anyone know how I assign the result of the statement to a variable. > e.g the result of: > > value="off" > value == "on" ? "YES" : "NO" >>> "NO" do you really need the "YES" and "NO"? Why not just assign the other_value to true or false? i.e. other_value = (value=="on") Then you are dealing with booleans which are less prone to error imho. -- Posted via http://www.ruby-forum.com/.