Ruby: why do while and until not return last line they execute from a function? -
I hope the loop of a time comes back to execute the last statement, but does not return a function Does
(1) It starts working .. (2) This does not work as much as I expected. I hope 10 will be returned and stored in Question: Update: Outlined as @DaveNewton, in (1) , I thought I Was doing: but I was actually doing: Both in their instances, For the same: As a
[10] pry (main)> Counter = 0 = & gt; 0 [11] PRI (Main) & gt; A = counter + = 1 while the counter & lt; 10 = & gt; Nil [12] PRI (Main) & gt; A = & gt; 10
b .
[19] Pry (main)> gt; Def increase (Terminal_value) [19] PRI (Main) * Counter = 0 [19] PRI (Main) * While counter & lt; Terminal_Value [19] PRI (Main) * Counter + = 1 [19] PRI (Main) * End [19] PRE (Main) * end = & gt; : Increase in salary [20] PRI (Main)> B = increment (10) = & gt; Nil [21] PRI (Main) & gt; B = & gt; Zero
Zero return from the assignment statement?
b assigned to
10 ?
one = (counter + = 1 counter while <10)
(a = counter + = 1) counter & lt; 10
while
Zero .
while is a result of
zero as long as
break is used to provide value Is done for
while loop
zero until
Break is used, by the
result loop.
Comments
Post a Comment