开发者

Ruby: type() global method

开发者 https://www.devze.com 2023-03-27 18:20 出处:网络
I\'m just curious what the type() global method is. I used it a = 1 puts type(a) and just go开发者_开发知识库t \"wrong number of arguments (1 for 0)\".It’s a deprecated equivalent of class, and i

I'm just curious what the type() global method is.

I used it

a = 1
puts type(a)

and just go开发者_开发知识库t "wrong number of arguments (1 for 0)".


It’s a deprecated equivalent of class, and it’s gone in 1.9.

>> send :class
=> Object
>> 1.type
(irb):5: warning: Object#type is deprecated; use Object#class
=> Fixnum


Deprecated synonym for Object#class.

http://apidock.com/ruby/Object/type

0

精彩评论

暂无评论...
验证码 换一张
取 消