On Fri, 18 Jan 2002 10:33:23 +1100, Sung Moon wrote:

> Can we use constant for a method name?
> 
> In ruby-token.rb of irb
> def Token() is used for method definition.
> 
> It seems no error occurred.
> 
> I think a method name should begin with lower case.
> 
> Is it allowed? When? What's the difference?

I think Ruby can tell that you're writing a method by
the context (ie, the fact that it says "def" before it).

I'm used to writing my method names with initial uppercase
characters (I've changed for Ruby, just to fit in with
the norm), and I didn't have any problems when I first
started.

However, I know this won't work for parameters to methods. A
mate of mine was writing, as his first attempt at Ruby, some
code to play with dates and times.  He wrote a method that
accepted a number as hours, minutes and seconds and tried
something like ...

   def validate(HMS)
   end

The error message confused him completely.  It was almost
enough to put him off learning Ruby, until I pointed out
what the issue was.