Integer 和 Fixnum 有什么区别? [英] What is the difference between Integer and Fixnum?

查看:48
本文介绍了Integer 和 Fixnum 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 Fixnum 类继承自 Integer 类.但它们之间的实际区别是什么?是否有我们有时使用 Fixnum,有时使用 Integer 代替的用例?

I know that the Fixnum class inherits from the Integer class. But what is the actual difference between them? Are there any use cases where we sometimes use Fixnum, and sometimes use Integer instead?

推荐答案

你从不使用"Integer.它是一个抽象类,其工作是为其子项(FixnumBignum)赋予方法.实际上,在任何情况下,您都不会要求一个对象的类并被告知它是一个 Integer.

You never "use" Integer. It is an abstract class whose job is to endow its children (Fixnum and Bignum) with methods. Under effectively no circumstances will you ever ask for an object's class and be told that it is an Integer.

这篇关于Integer 和 Fixnum 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆