# How do I iitialze this class?

**URL:** <https://www.ruby-forum.com/t/how-do-i-iitialze-this-class/146642>\
**Category:** Ruby\
**Created:** [August 23, 2008, 1:47pm UTC](https://www.ruby-forum.com/t/how-do-i-iitialze-this-class/146642 "2008-08-23T13:47:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsn1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@jsn1](https://www.ruby-forum.com/u/jsn1)\
**Post date:** [August 23, 2008, 1:47pm UTC](https://www.ruby-forum.com/t/how-do-i-iitialze-this-class/146642/1 "2008-08-23T13:47:40Z")

</div>

When I try to initialize this class

class Ticket  
def event  
$event  
end  
end

ticket = Ticket.new(“Can’t really be specified yet…”)  
puts ticket.event

I get an error message:  
undefined method `event’ for nil:NilClass

Why?

---

<div class="post-metadata">

**Author:** ![jsn1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@jsn1](https://www.ruby-forum.com/u/jsn1)\
**Post date:** [August 23, 2008, 1:58pm UTC](https://www.ruby-forum.com/t/how-do-i-iitialze-this-class/146642/2 "2008-08-23T13:58:00Z")

</div>

On Saturday 23 August 2008, Pepe S. wrote:

> I get an error message:  
> undefined method `event’ for nil:NilClass
> 
> Why?

Try this:

class Ticket

attr\_reader :event

def initialize msg  
@event = msg  
end

end

Stefano
