Nuby: VisualuRuby, menutest.rb example with check boxes in s

I’m back to looking at visualuRuby, have two quick questions about this
program:
http://vruby.sourceforge.net/sample/menutest.rb
Basically, I don’t understand this line: @checking.checked = ! @
checking.checked?

I added the following which gives me the desired results.

if @checking.checked?
@label.caption=“checked”
else
@label.caption=“unchecked”
end

First question:
what does ‘= ! @variable’ do anyway? I’ve never seen an example that
did
that.
Second question:
How can what I added be turned into a one-liner?

Jason M. wrote:

what does ‘= ! @variable’ do anyway? I’ve never seen an example that did
that.
= does what you think it does. ! is the unary ‘not’ operator. !false ==
true and !true == false.

Second question:
How can what I added be turned into a one-liner?
@label.caption = @checking.checked? ? “checked” : “unchecked”

On 12/27/06, Devin M. [email protected] wrote:

Jason M. wrote:

else
@label.caption=“unchecked”
end

First question:
what does ‘= ! @variable’ do anyway? I’ve never seen an example that did
that.
Second question:
How can what I added be turned into a one-liner?

Read “! @variable” as “not @variable”. The value of the expression is
either true or false. If @variable is anything other than false or nil,
then “! @variable” is false. If @variable is false or nil, then “!
@variable” is true.

Use the ternary ?: operator to turn your code into a one-liner. Your
code is equivalent to

@label.caption = @checking.checked? ? “checked” : “unchecked”