Hi Slipper Spe,

You should put "greeter" outside the class TEST. You cannot call a method
inside a class.

Regards,
Yuanhang.


On Thu, Jan 16, 2014 at 10:19 AM, Slipper Spe <lists / ruby-forum.com> wrote:

> Today, I started to try to learn ruby. When I went to make my first
> method, I kept receiving an error "undefined local variable or method."
>
> I tried looking up how to make methods in Ruby online, so that I would
> be sure its not my own fault. I copy pasted several examples into my
> ide, all of which returned the same error.
>
> I made a simple method (below) and I get the same error: <class:TEST>':
> undefined local variable or method `greeter' for TEST:Class (NameError)
>
>
> class TEST
>
>   def greeter()
>     puts 'Hi'
>   end
>   greeter
>
> end
>
>
> The built in ruby methods work fine. Is there something wrong with what
> I'm doing?
>
> --
> Posted via http://www.ruby-forum.com/.
>