Re: ruby and true



On 30.04.2007 16:42, aidy.lewis@xxxxxxxxxxxxxx wrote:
Hi,

I have some code the checks whether some text is on the HTML page

@@log.test_results(ie.contains_text('Dashboard')

I should get a TRUE (it's there), but it is returning the figure 62.
Is anything > 0 in Ruby true? If so, why, and shouldn't the object
automatically change to boolean?

My xml then is falling through

if result == TRUE then
test_status = @test.add_element 'teststatus'
test_status.text = 'PASS'


There's only two falses in Ruby: false and nil. Everything else is considered true.

Please note also, that it is usually a very bad idea to try to compare a boolean value with a boolean constant in a boolean context. Just use the value or use "!" or "not" to negate. This applies to all sorts of programming languages (just think of doing "if ( x == TRUE )" in C...

Kind regards

robert
.



Relevant Pages

  • Re: Code to check for HTML messages being sent
    ... Private Sub myItem_Send(Cancel As Boolean) ... MsgBox "have a great day!" ... is it possible to edit the HTML code of the message using VBA? ...
    (microsoft.public.outlook.program_vba)
  • Re: problem with string.Contains()
    ... boolean = false; ... retrieve the html from a webpage and now I'm searching through this ... this webpage contains 4 html tables. ...
    (microsoft.public.dotnet.languages.csharp)
  • Boolean Visible Property problem
    ... I'm new to asp.net and c# and I've got stuck on an apparently simple ... This is the HTML: ... I've tried getting isNotTopto return a boolean but it doesn't help. ... John South ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [PHP] checkbox unchecked
    ... A boolean value should evaluate correctly ... then foo will be 1, ... If you will note, without specifically setting the value, html will ... PHP General Mailing List ...
    (php.general)
  • Re: [PHP] checkbox unchecked
    ... A boolean value should evaluate correctly ... then foo will be 1, ... Not that you said otherwise, but if the programmer does not set the value for a checkbox, html will provide values -- that may lead to confusion for newer programmers. ...
    (php.general)