Question: I'm looking over someone's codes and wondering about the difference between: 

```
def blah
  @hello ||= [1,2,3].collect{|x| x+1}
end

```

and

```
def blah 
  @hello = [1,2,3].collect{|x| x+1}
end

```

I understand that `||=` means "or equal", but why do we need it? An example would be great.

Also, for the `collect` method, let's say I have an array:

```
a = [1,2,4,5]

```

and I wanted to find the array that contains integers that are greater than `2`, how can I use `collect` with that?

```
a.collect{|x| x>2} # => [false, false, true, true]

```

I want `[4,5]`.

Answer: 
> 
> a = [1,2,4,5] and I wanted to find the array that contains integers that are greater than 2,
> 
> 
> 

Here we go using [`Array#select`](http://www.ruby-doc.org/core-2.1.0/Array.html#method-i-select):

```
 a.select{|e| e > 2 } # => [4,5]

```

Explanation of the part `@hello ||= [1,2,3].collect{|x| x+1}` can be found [What does ||= (or equals) mean in Ruby?](https://stackoverflow.com/questions/995593/what-does-or-equals-mean-in-ruby)
The page [What does ||= (or-equals) mean in Ruby?](https://stackoverflow.com/questions/995593/what-does-or-equals-mean-in-ruby) does not mention the "proxy design pattern", which it is in a nutshell.

The first time you call that line, the .select stuff gets evaluated. The second time, the system re-uses the `@hello` value, without re-assigning it. Due to "boolean short-circuiting", things to the right of a `||` don't evaluate, if the left side is not `false` or `nil`.

(Also, if you never evaluated `@hello` before, Ruby automagically creates one, and assigns `nil` to it. So Ruby lets you proxy in one line, as an optimization.)