Skip to content

Instantly share code, notes, and snippets.

@sandeepseshadri
Last active November 16, 2016 21:35
Show Gist options
  • Save sandeepseshadri/3ab7e8fa840b27b32ec157e953406792 to your computer and use it in GitHub Desktop.
Save sandeepseshadri/3ab7e8fa840b27b32ec157e953406792 to your computer and use it in GitHub Desktop.
Mainly for php developers trying to make sense of ruby syntax
1. def send_message ------> public function sendMessage
2. begin rescue end ---> try catch
3. to_s ---> to string
4. $! ---> get_last_error()
5. self.save! ---> just a convention notifying side effect
6. user.is_admin? --> convention notifying it returns a boolean
7. user.send_message ---> $user.sendMessage() - no need for () if there are no parameters
8. self.account_id ---> $this->account_id
9. user.do_something(self) ---> $user->doSomething($this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment