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

**URL:** <https://www.ruby-forum.com/t/ruby-doesnt-need-equals-signs-for-assigment/147490>\
**Category:** Ruby\
**Created:** [September 2, 2008, 1:10pm UTC](https://www.ruby-forum.com/t/ruby-doesnt-need-equals-signs-for-assigment/147490 "2008-09-02T13:10:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [September 2, 2008, 1:10pm UTC](https://www.ruby-forum.com/t/ruby-doesnt-need-equals-signs-for-assigment/147490/1 "2008-09-02T13:10:42Z")

</div>

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

On this page:

> **[ActionMailer::Base](https://api.rubyonrails.org/classes/ActionMailer/Base.html)**
>
> Action Mailer allows you to send email from your application using a mailer model and views. Mailer Models To use Action Mailer, you need to create a mailer model.

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 “removed\_email\_address@domain.invalid”  
subject “New account information”  
body :account =\> recipient  
end  
end

TIA, Pet

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [September 2, 2008, 1:19pm UTC](https://www.ruby-forum.com/t/ruby-doesnt-need-equals-signs-for-assigment/147490/2 "2008-09-02T13:19:15Z")

</div>

2008/9/2 Peter A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I’m new to Ruby… do you need ='s signs for assigment?
> 
> On this page:
> 
> [ActionMailer::Base](http://api.rubyonrails.org/classes/ActionMailer/Base.html)
> 
> 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. 😉

> class Notifier \< ActionMailer::Base  
> def signup\_notification(recipient)  
> recipients recipient.email\_address\_with\_name  
> from “removed\_email\_address@domain.invalid”  
> subject “New account information”  
> body :account =\> recipient  
> end  
> end

These are all method invocations.

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [September 2, 2008, 1:19pm UTC](https://www.ruby-forum.com/t/ruby-doesnt-need-equals-signs-for-assigment/147490/3 "2008-09-02T13:19:50Z")

</div>

> 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 “removed\_email\_address@domain.invalid”  
> 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(“removed\_email\_address@domain.invalid”)  
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.

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [September 2, 2008, 1:40pm UTC](https://www.ruby-forum.com/t/ruby-doesnt-need-equals-signs-for-assigment/147490/4 "2008-09-02T13:40:54Z")

</div>

> These are all method invocations.

OHHHHHHH!!! DUH! Thanks so much!

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [September 3, 2008, 12:43pm UTC](https://www.ruby-forum.com/t/ruby-doesnt-need-equals-signs-for-assigment/147490/5 "2008-09-03T12:43:03Z")

</div>

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.
