# [Newbies] Why the variable "a" is different out of the loop when codes are executed as a whole or by two steps?

RedTigerFish chihuyu at gmail.com
Sat Nov 18 07:36:26 UTC 2017

```

Hello, friends.

This problem which confuses me comes from a  question
<http://forum.world.st/quot-Print-specific-integers-quot-Error-message-how-to-improve-and-what-causes-that-td5025067.html>
I asked in "Squeak - Beginners" days ago.

These are some special integers: myArray := #(2 32 44 67 89 111 123)
These special integers need to be specially labelled from integer 1 to 130.
The rest normal numbers which myArray doesn't include will be printed also.

Here's the code:

*|a n myArray|

myArray := #(2 32 44 67 89 111 123).

n := 1.
a := myArray at: n.

1 to: 130 do: [:i|
i = a
ifTrue: [
Transcript show: ('Special number:  i = {1}, a = {2}' format:
{i. a}).
Transcript cr.
n := n + 1.
n = 8
ifTrue: [a := 'I am no longer a number'.]
ifFalse: [a := myArray at: n. ].
]
ifFalse: [
Transcript show: ('i = {1}, a = {2}' format: {i. a}).
Transcript  cr.
].
].

Transcript show: a; cr.     'Last line'
*

Now comes something that makes my head big.

If I choose everything and do them, the last line, which should tell me what
a is when program jumps out of the loop, exactly shows that a is "I am no
longer a number".

However, if I choose everything except the last line, and do them. After
that, I do the last line. The output is nil.

Why is a nil ?   Why's that?

In order to make my question explicit, I recorded a video:

-----
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
```