If you want to use if-elsif-else:

if something
  # do something
elsif something_else
 # do something else
elsif something_else_take_two
 # there can be as much of this as you need
else
 # do something
end

I recommend http://whytheluckystiff.net/ruby/pickaxe/ for further reading.

Zeljko

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jeff Wood
Sent: Thursday, December 15, 2005 1:28 AM
To: [email protected]
Subject: Re: [Wtr-general] Else-if statements

Usually it's best to use a case statement if you start to have more
than if/else conditions.

case (do stuff)
  when (result1):
    ie.links[1].click
  when (result2):
    ie.links[2].click
  else:
    ie.links[3].click
end

It tends to make it easier to read & easier to extend should you ever
need additional conditions...

I highly recommend case ... there is a *LOT* of power inside those
"when" criteria.

j.

On 12/14/05, Torres, Ben (HQP) <[EMAIL PROTECTED]> wrote:
> Hi,
>
> What is the syntax I use for else-if statements?  I am using the code
> below, but I am getting an error:
>
> If cond1
>         ie.links[1].click
> Else-if cond2
>         ie.links[2].click
> Else
>         ie.links[3].click
> End
>
>
> Thanks in advance...
>
>
> _______________________________________________
> Wtr-general mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/wtr-general
>


--
"Remember. Understand. Believe. Yield! -> http://ruby-lang.org";

Jeff Wood

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to