Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Nuby: VisualuRuby, menutest.rb example with check boxes in submenus
Tim Hunter
12/27/2006 2:33:00 PM
Jason Mayer wrote:
> I'm back to looking at visualuRuby, have two quick questions about this
> program:
>
http://vruby.sourceforge.net/sample/m...
> 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?
>
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"
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Nuby: VisualuRuby, menutest.rb example with check boxes in submenus
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password