Ruby doesn't need equal's signs for assigment?

I’m new to Ruby… do you need ='s signs for assigment?

On this page:

I see this example over and over… where are the equal’s signs???

class Notifier < ActionMailer::Base
def signup_notification(recipient)
recipients recipient.email_address_with_name
from “[email protected]
subject “New account information”
body :account => recipient
end
end

TIA, Pet

2008/9/2 Peter A. [email protected]:

I’m new to Ruby… do you need ='s signs for assigment?

On this page:

ActionMailer::Base

I see this example over and over… where are the equal’s signs???

I can confirm that there are no equal signs in the code. :wink:

class Notifier < ActionMailer::Base
def signup_notification(recipient)
recipients recipient.email_address_with_name
from “[email protected]
subject “New account information”
body :account => recipient
end
end

These are all method invocations.

Kind regards

robert

I see this example over and over… where are the equal’s signs???

class Notifier < ActionMailer::Base
def signup_notification(recipient)
recipients recipient.email_address_with_name
from “[email protected]
subject “New account information”
body :account => recipient
end
end

You need = signs for assignment. In ActionMailer those are implemented
as
methods to make the syntax a bit cleaner. A more verbose way to write
the
above using full method call syntax:

class Notifier < ActionMailer::Base
def signup_notification(recipient)
self.recipients(recipient.email_address_with_name)
self.from(“[email protected]”)
self.subject(“New account information”)
self.body(:account => recipient)
end
end

This is why Ruby is known for being a good language for writing DSLs
(domain-specific languages, ie mini-languages for describing specific
problems), since its method call syntax does not require ‘self’ and lots
of
parentheses.

These are all method invocations.

OHHHHHHH!!! DUH! Thanks so much!

Peter A. wrote:

These are all method invocations.

OHHHHHHH!!! DUH! Thanks so much!

Some people don’t like parentheses. Personally I use them abundantly
(even though I’ve never studied Lisp). Most of the time parentheses make
things clearer.