Topic: Writing Ruby Methods - How are they like PHP functions?

As I get more into rails I realize the need to learn more about Ruby.  I've been going through the ruby docs and I've got a handle on a lot of the various class methods available.

However, when it comes to writing my own methods in my Rails models I'm a bit confused. 

The first thing that I'm confused with is the following syntax.

def my_function=(arg)
  puts arg

What's the significance of the =() part.  Why do I need the = sign?

In PHP if I wanted to create a function that could handle multiple arguments I would do something like:

function my_function($arg1, $arg2, $arg3){
echo "$arg1, $arg2, $arg3";

Does the same work in ruby?
def my_function=(arg1, arg2, arg3)
  puts arg1
  puts arg2
  puts arg3

Finally, in PHP if I want to have an optional argument, or an argument in a functiont that if not specified when the function is called will use a default value I would use:
function my_function($default="blue"){
  echo $default; // blue

Re: Writing Ruby Methods - How are they like PHP functions?

A function like attribute=(newvalue) is kind of like an overloaded = operator.  It lets you define the behavior for using the =.  Most of the time  you wouldn't use a function like that. 
Most functions can take multiple parameters, yes.  def foobar(a, b, c)
Defaults are pretty much the same.  def foobar(a, b='', c=false)
I would really suggest the book 'Programming Ruby'.  Besides being a good tutorial, it has hundreds of pages of easy to lookup API references. - Brewery and Brewpub management powered by RoR

Re: Writing Ruby Methods - How are they like PHP functions?

Thanks for the reply!

I've been browsing through this book each time I'm at the bookstore but I think I'll finally pick it up.