Advertisement
kn0tsel

Ruby-03

May 4th, 2013
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  ~ Similarities with C ~
  2.  
  3. As with C, in Ruby,…
  4.  
  5.  * You may program procedurally if you like (but it will still be object-oriented behind the scenes).
  6.    
  7.  * Most of the operators are the same (including the compound assignment and also bitwise operators).
  8.  
  9.  * Though, Ruby doesn’t have ++ or --.
  10.    You’ve got __FILE__ and __LINE__.
  11.  
  12.  * You can also have constants, though there’s no special const keyword.
  13.    Const-ness is enforced by a naming convention instead— names starting with a capital letter
  14.    are for constants.
  15.    
  16.  * Strings go in double-quotes. Strings are mutable.
  17.    
  18.  * Just like man pages, you can read most docs in your terminal window—though using the ri command.
  19.  
  20.  * You’ve got the same sort of command-line debugger available.
  21.  
  22.  
  23. ~ Similarities with C++ ~
  24.  
  25. As with C++, in Ruby,…
  26.  
  27.   *  You’ve got mostly the same operators (even ::).
  28.      << is often used for appending elements to a list. One note though:
  29.      with Ruby you never use -> it’s always just ..
  30.   *  public, private, and protected do similar jobs.
  31.   *  Inheritance syntax is still only one character, but it’s < instead of :.
  32.   *  You may put your code into “modules”, similar to how namespace in C++ is used.
  33.   *  Exceptions work in a similar manner, though the keyword names have been changed
  34.      to protect the innocent.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement