So I create a class in ruby:

```
class User
  def initialize
  end
end

```

Now say I want to create a attribute that is a hash with a getter/setter, I'm confused as to the options I have doing this.

If I do this:

```
class User
  attr_accessor :some_hash
end

```

But I don't want this hash to be nil ever, always an empty hash.

I'm confused when I should do:

```
def some_hash
  self.some_hash ||= {}
end

```

and do:

```
def some_hash
  @some_hash ||= {}
end

```

What is the difference?

If I don't use the attr\_accessor, I have to create both the reader and writer (or getter/setter):

```
def some_hash=()
end

def some_hash
end

```

**I'm hoping someone can clear up the options I would have for creating a some\_hash attribute which is a hash, and that never returns a nil if it is empty.**

i.e. using attr\_accessor, manually creating the methods, and finally when to use @some\_hash and self.some\_hash