How to initialize a local variable in its declaration in Eiffel?

I tried to do this:

local condition: BOOLEAN condition := true do 

And something like this:

 local condition: BOOLEAN := true do 

Obviously, none of them work, but I need to initialize the variable inside the declaration, because I do not want the variable to be reinitialized if the repeat command is executed. I looked in the Eiffel documentation and in the textbook, but they always internalize the variables in the body of the operation.

+4
source share
3 answers

Each variable is initialized in Eiffel, so locally they get their default value, which is false for BOOLEAN.

Note that for replay, variables are not initialized again by default, so you can use this with:

 test local retrying: BOOLEAN do if retrying then do_something_else else retrying := true first_try end; rescue handle_error retry end 
+7
source

I think you can use

 local condition: BOOLEAN = true do 
0
source
 local condition: BOOLEAN do condition := True ... 
0
source

Source: https://habr.com/ru/post/1380643/


All Articles