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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With