Skip to content

Seven Languages in Seven Weeks


  • Author: [[Tate, Bruce A.]]


So, everything but nil and false evaluate to true. C and C++ programmers, take note. 0 is true! — location: 602 ^ref-5928

Ruby is strongly typed,[3] meaning you’ll get an error when types collide. — location: 662 ^ref-47635

Ruby does not do type checking until you actually try to execute code. This concept is called dynamic typing. — location: 678 ^ref-7792

Duck typing doesn’t care what the underlying type might be. If it walks like a duck and quacks like a duck, it’s a duck. — location: 698 ^ref-15369

Duck typing is extremely important when it comes to clean object-oriented design. An important tenet of design philosophy is to code to interfaces rather than implementations. If you’re using duck typing, this philosophy is easy to support with very little added ceremony. If an object has push and pop methods, you can treat it like a stack. If it doesn’t, you can’t. — location: 699 ^ref-34699

A symbol is an identifier preceded with a colon, like :symbol. Symbols are great for naming things or ideas. Although two strings with the same value can be different physical strings, identical symbols are the same physical object. — location: 843 ^ref-46926

Notice that you didn’t have to type in the braces. These braces are optional for the last parameter of a function. — location: 880 ^ref-49206

A code block is a function without a name. You can pass it as a parameter to a function or a method. — location: 882 ^ref-49253

The code between braces is called a code block. — location: 889 ^ref-33468

You’ll see Ruby libraries that use blocks to process each line of a file, do work within an HTTP transaction, and do complex operations over collections. Ruby is a block party. — location: 973 ^ref-51012

Fixnum is an instance of the class Class. — location: 1016 ^ref-38389

attr_accessor, defining an instance variable, an accessor, and a setter. — location: 1062 ^ref-58964

Object-oriented languages use inheritance to propagate behavior to similar objects. When the behaviors are not similar, either you can allow inheritance from more than one class (multiple inheritance) or you can look to another solution. Experience has shown that multiple inheritance is complicated and problematic. Java uses interfaces to solve this problem. Ruby uses modules. — location: 1078 ^ref-63429