Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From Ruby's <a href="http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-python/" rel="nofollow noreferrer">website</a>:</p> <p>Similarities As with Python, in Ruby,...</p> <blockquote> <ul> <li>There’s an interactive prompt (called irb).</li> <li>You can read docs on the command line (with the ri command instead of pydoc).</li> <li>There are no special line terminators (except the usual newline).</li> <li>String literals can span multiple lines like Python’s triple-quoted strings.</li> <li>Brackets are for lists, and braces are for dicts (which, in Ruby, are called “hashes”).</li> <li>Arrays work the same (adding them makes one long array, but composing them like this <code>a3 = [ a1, a2 ]</code> gives you an array of arrays).</li> <li>Objects are strongly and dynamically typed.</li> <li>Everything is an object, and variables are just references to objects.</li> <li>Although the keywords are a bit different, exceptions work about the same.</li> <li>You’ve got embedded doc tools (Ruby’s is called rdoc).</li> </ul> </blockquote> <p>Differences Unlike Python, in Ruby,...</p> <blockquote> <ul> <li>Strings are mutable.</li> <li>You can make constants (variables whose value you don’t intend to change).</li> <li>There are some enforced case-conventions (ex. class names start with a capital letter, variables start with a lowercase letter).</li> <li>There’s only one kind of list container (an Array), and it’s mutable.</li> <li>Double-quoted strings allow escape sequences (like \t) and a special “expression substitution” syntax (which allows you to insert the results of Ruby expressions directly into other strings without having to "add " + "strings " + "together"). Single-quoted strings are like Python’s r"raw strings".</li> <li>There are no “new style” and “old style” classes. Just one kind.</li> <li>You never directly access attributes. With Ruby, it’s all method calls.</li> <li>Parentheses for method calls are usually optional.</li> <li>There’s public, private, and protected to enforce access, instead of Python’s <code>_voluntary_ underscore __convention__</code>.</li> <li>“mixin’s” are used instead of multiple inheritance.</li> <li>You can add or modify the methods of built-in classes. Both languages let you open up and modify classes at any point, but Python prevents modification of built-ins — Ruby does not.</li> <li>You’ve got true and false instead of True and False (and nil instead of None).</li> <li>When tested for truth, only false and nil evaluate to a false value. Everything else is true (including 0, 0.0, "", and []).</li> <li>It’s elsif instead of elif.</li> <li>It’s require instead of import. Otherwise though, usage is the same.</li> <li>The usual-style comments on the line(s) above things (instead of docstrings below them) are used for generating docs.</li> <li>There are a number of shortcuts that, although give you more to remember, you quickly learn. They tend to make Ruby fun and very productive.</li> </ul> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload