small medium large xlarge

29 Sep 2015, 23:30
Marc Chanliau (1 post)

In the book (Programming Ruby 1.9 & 2.0), the authors refer to Float in the following context @price = Float(price) as a “method.” It seems that Float is a class, not a method. Am I wrong? I see this topic has been raised before, but based I haven’t found any reference to Float as a method.

01 Dec 2016, 10:08
Marco V. (1 post)

Yes, it’s also a Kernel method.

Object.method(:Float).class #=> Method

Object.method(:Float).owner  #=> Kernel

You must be logged in to comment