Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ruby is a <a href="http://en.wikipedia.org/wiki/Dynamically_typed#Dynamic_typing" rel="nofollow">dynamically typed</a> language; like many dynamically typed languages, it adheres to <a href="http://en.wikipedia.org/wiki/Duck_typing" rel="nofollow">duck typing</a> -- from the English Idiom, "If it walks like a duck and quacks like a duck, then it's a duck."</p> <p>The upside is that you don't have to declare <em>types</em> on any of your variables or class members. The restrictions on what types of objects you can store into the variables or class members comes only from <em>how you use them</em> -- if you use <code>&lt;&lt;</code> to "write output", then you could use a file or array or string to store the output. This can greatly increase the flexibility of your classes. (How many times have you been upset that an API you must use required a <code>FILE *</code> C standard IO file pointer rather than allowing you to pass in a buffer?)</p> <p>The downside (and, in my mind, it's a big one) is that there's no easy way for you to determine what data types you can safely store into any given variable or member. Perhaps once every leap year, a new method is called on a variable or member -- your program might crash with a <code>NoMethodError</code>, and your testing might have missed it completely because it relied on inputs you might not realize were vital. (This is a fairly contrived example. But corner cases are where most programming flaws exist and dynamic typing makes corner cases that much harder to discover.)</p> <p>In short: there's no restriction on what you can store in your Address fields. If it supports the methods you call on those objects, it is -- as far as the language is concerned -- <em>an <code>Address</code></em>. If it doesn't support the methods you need, then it will crash during sufficiently-exhaustive testing.</p> <p>Just be sure to <em>use the testing facilities</em> to their fullest, to make sure you're exercising your code sufficiently to find any objects not fully compliant with a required API.</p>
    singulars
    1. This table or related slice is empty.
    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