I simplified the problem I've got with following code:

```
def self.foo()
    array = [0,3,5,10,4,6,9,7]

    array.each do |arrayelement|
        name = "Ruts" if arrayelement == 5
        puts name
    end 
end

```

When a certain element of the array equals a constant, a string should be written in the variabele. Every element in the array is unique. The problem is that it writes "Ruts" into variable name when arrayelement = 5, but in the next iteration of the each loop it overwrites it with nil. Here's the output of the method.

```
nil
nil
Ruts
nil
nil
nil
nil
nil

```

How can I change my code so variable name = Ruts instead of nil for the next iterations?