-
Book Overview & Buying
-
Table Of Contents
Polished Ruby Programming - Second Edition
By :
In the previous section, when discussing the notion of type, we looked at CRuby internal types as well as classes. We also saw how the static typing systems were not able to correctly type-check a simple example. It may be fun to imagine what a correct Ruby typing system would look like. By correct, we refer to a system that would correctly flag cases where Ruby would raise a TypeError, ArgumentError, or NoMethodError, outside of places where those are raised manually, with no false positives or false negatives, and without type annotations. Consider the following method:
def obj_size(obj) = obj.size
What could be considered the correct type signature of the obj_size method? Well, with no further constraints, the type signature of the method would be that it accepts any object that responds to size, where size can be called with no arguments, and could potentially return any object. This is correct, because if the method did not respond to size...
Change the font size
Change margin width
Change background colour