Missing kEND for if statement, but not for a case statement?

I am having some trouble figuring out why I keep getting an unexpected
kENSURE expecting kEND error.

I have to sets of code and the first set uses a case statement with the
same
amount of end keywords. This set runs fine. The second set uses an if
statement and will not pass a syntax check. Any advice is greatly
appreciated. I really need to figure out how to go with the if
statement
because the === operator that case statements use do not work the way I
need
them to when a regex object is placed in the right side of the
expression.
This is a rough example of my syntax. The actual code has different
values
but the structure is the same. I’ve used VIM with matchit and can not
find
any errors.

1st set;

begin
loopbreak = false
while loopbreak != true
str = gets
case(str)
when ‘help’, ‘HELP’
puts help
when ‘quit’, ‘QUIT’
loopbreak = true
when ‘options’, ‘OPTIONS’
puts options
else
puts “{#str} is not a valid command”
end
end

ensure
somehousecleaning()
end

2nd set

begin
loopbreak = false
while loopbreak != true
str = gets
if str =~ /help|HELP/
puts help
else if str =~ /quit|QUIT/
loopbreak = true
else if str =~ /options|OPTIONS/
puts options
else
puts “{#str} is not a valid command”
end
end

ensure
somehousecleaning()
end

On 6/27/07, Nathan T.-Hoover [email protected] wrote:

    else
        puts "{#str} is not a valid command"
    end
end

ensure
somehousecleaning()
end

The “else if” construct is elsif in ruby. doing else if will start an
actual new if statement that needs to be ended.

That is excellent. Thank you. I thought it was elseif but when I used
that
in my text editor that has support for ruby it did not colorize it as a
keyword, however when I used else if it did so I was mislead into
believing
I had the correct syntax.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs