Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby assignment methods [duplicate]

Tags:

ruby

Possible Duplicate:
Ruby Assignment Syntax

I don't get the concept of an assignment method in Ruby:

def current_user=(user)
  @user = user
end

If the method is declared like that, then how can you put a space before the equals sign?

def some_method(user)
  self.current_user = user
end
like image 728
LanguagesNamedAfterCofee Avatar asked Jun 03 '11 02:06

LanguagesNamedAfterCofee


1 Answers

Assignment methods are a special case of the ruby parser. There are others like [](..) and []=(..).

like image 72
cam Avatar answered Sep 30 '22 02:09

cam