O'Reilly logo

Ruby Phrasebook by Jason Clinton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 1. Converting Between Types

The word “type” comes with a lot of baggage and I use it deliberately here. Programmers coming from other languages will likely expect Ruby, like all languages, to implement certain core “types”: integers, floats, strings, characters, etc. However, in Ruby there really isn’t such a thing as a traditional primitive type. Even integers are stored as instances of the Fixnum (or Bignum) class. They are objects just like any other. If you are new to Ruby, you should keep repeating this to yourself as you are coding: “everything is an object, everything is an object, ...”. That’s the rule to swim or sink by in Ruby. Absolutely everything around is an object: an instance of a class.

Also, keep in mind that the rigidness ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required