Skip to content

Commit

Permalink
Add Kernel#Float
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Oct 17, 2013
1 parent 24e3e62 commit cae238d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions corelib/kernel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,16 @@ def Integer(value, base = `undefined`)
end
end

def Float(value)
if String === value
`parseFloat(value)`
elsif value.respond_to? :to_f
value.to_f
else
raise TypeError, "can't convert #{value.class} into Float"
end
end

def is_a?(klass)
%x{
var search = #{self}._klass;
Expand Down

0 comments on commit cae238d

Please sign in to comment.