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