Reputation: 4767
I tried to do this:
local
condition: BOOLEAN
condition := true
do
And something like this:
local
condition: BOOLEAN := true
do
Obviously neither work, but I need to initialize a variable inside the declaration because I don't want the variable to re-initialize if a retry instruction is executed. I looked in Eiffel's oficial documentation and in tutorial but they always intitialize variables in the body of the operation.
Upvotes: 4
Views: 1565
Reputation: 2112
Every variable is initialised in Eiffel, so in local they all get their default value, which is false for BOOLEAN.
Note that for a retry the variables are not initialised to their default again, so you can use that with:
test
local
retrying: BOOLEAN
do
if retrying then
do_something_else
else
retrying := true
first_try
end;
rescue
handle_error
retry
end
Upvotes: 8