# Valid name for a method

**URL:** <https://www.ruby-forum.com/t/valid-name-for-a-method/93186>\
**Category:** Ruby\
**Created:** [April 28, 2007, 8:48pm UTC](https://www.ruby-forum.com/t/valid-name-for-a-method/93186 "2007-04-28T20:48:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![German\_Monfort](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e79b87/32.png) [@German\_Monfort](https://www.ruby-forum.com/u/German_Monfort)\
**Post date:** [April 28, 2007, 8:48pm UTC](https://www.ruby-forum.com/t/valid-name-for-a-method/93186/1 "2007-04-28T20:48:42Z")

</div>

Hi all,

I’m trying to add a new method to a class but I want to name it like  
`<<<' or`++’, etc but it seems that these characters are not allowed

irb(main):001:0\> class A  
irb(main):002:1\> def \<\<\< arg  
irb(main):003:2\> end  
irb(main):004:1\> end  
SyntaxError: compile error  
(irb):2: syntax error, unexpected ‘\<’, expecting ‘\n’ or ‘;’  
def \<\<\< arg  
^  
(irb):4: syntax error, unexpected kEND, expecting $end  
from (irb):4  
from :0

Is there a workaround to have a `\<\<\<’ method so I can use it like a \<\<\<  
b or  
even a.\<\<\< b?

---

<div class="post-metadata">

**Author:** ![German\_Monfort](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e79b87/32.png) [@German\_Monfort](https://www.ruby-forum.com/u/German_Monfort)\
**Post date:** [April 28, 2007, 9:11pm UTC](https://www.ruby-forum.com/t/valid-name-for-a-method/93186/2 "2007-04-28T21:11:45Z")

</div>

On Sun, 29 Apr 2007, German Monfort wrote:

> (irb):2: syntax error, unexpected ‘\<’, expecting ‘\n’ or ‘;’  
> def \<\<\< arg  
> ^  
> (irb):4: syntax error, unexpected kEND, expecting $end  
> from (irb):4  
> from :0
> 
> Is there a workaround to have a `\<\<\<’ method so I can use it like a \<\<\< b or  
> even a.\<\<\< b?

harp:~ \> cat a.rb  
class C  
define\_method(’\<\<\<’){ 42 }  
end

p C.new.send(’\<\<\<’)

harp:~ \> ruby a.rb  
42

-a
