主页
论坛
新帖
最新消息
新帖
最新动态
制作互助群
登录
注册
Toggle sidebar
Toggle sidebar
菜单
安装应用
安装
回复主题
【进站必读】宝可饭堂社区全局规定v1.10
关于坚决维护同人创作社群秩序与共识的公告
论坛
独立开发
进阶教程
【TA】【ESS】07 类的多态性
禁用JavaScript。为了获得更好的体验,请在运行之前启用浏览器中的JavaScript。
您正在使用一款已经过时的浏览器!部分功能不能正常使用。
请尝试升级或使用
其他浏览器
。
信息
<blockquote data-quote="TAAAAAAA" data-source="post: 2354" data-attributes="member: 2783"><p><u>Applying knowledge on inheritance trees 利用类的父子关系链</u></p><p></p><p>This might sound useless, but it can actually come in handy.</p><p>Where normally, to determine if a number is a Float or a Fixnum, we’d use var.is_a?(Float) || var.is_a?(Fixnum), their inheritance trees reveal this:</p><p></p><p>Fixnum:</p><p></p><p>这是整数类的父子关系链:</p><p></p><p></p><p>Float:</p><p></p><p>这是浮点数类的父子关系链:</p><p></p><p></p><p>What we can gather from this, is that var.is_a?(Numeric) will be true for both Floats <em>and</em> Fixnums. You just have to know if any other classes use Numeric, but that isn’t the case, so it’s safe to use. If we did Comparable, for instance, we’d also get String in there, which we don’t want.</p><p></p><p>我们可以利用哪些类是共有的,而哪些类是独有的,等等的关系,来检查对象。</p></blockquote><p></p>
[QUOTE="TAAAAAAA, post: 2354, member: 2783"] [U]Applying knowledge on inheritance trees 利用类的父子关系链[/U] This might sound useless, but it can actually come in handy. Where normally, to determine if a number is a Float or a Fixnum, we’d use var.is_a?(Float) || var.is_a?(Fixnum), their inheritance trees reveal this: Fixnum: 这是整数类的父子关系链: Float: 这是浮点数类的父子关系链: What we can gather from this, is that var.is_a?(Numeric) will be true for both Floats [I]and[/I] Fixnums. You just have to know if any other classes use Numeric, but that isn’t the case, so it’s safe to use. If we did Comparable, for instance, we’d also get String in there, which we don’t want. 我们可以利用哪些类是共有的,而哪些类是独有的,等等的关系,来检查对象。 [/QUOTE]
验证
国内使用最多的GBA蓝本是?(3个汉字)
回复帖子
最新帖子
○ ESS19-20
【游戏引擎】构造/地震引擎简介
最新更新:TAAAAAAA
今天 18:29
入门教程
ESS
【同人游戏】口袋妖怪 地震 0.4.9
最新更新:TAAAAAAA
昨天 14:25
独立同人
✓ ESS20-21
如何制作一个隐藏性格,并令其无法在野生宝可梦身上出现?
最新更新:TAAAAAAA
昨天 14:24
开发问题
教程攻略
应该是这样
最新更新:幽冥魔帝
2026/07/07
同人改版讨论
mGBA西班牙火箭队五周目汉化版怎么调出内置修改器啊
最新更新:TAAAAAAA
2026/07/06
同人改版讨论
论坛统计
主题
611
消息
2,722
成员
3,849
最新成员
Contrary
联系我们
QQ
2201858342
邮箱
pokefans@qq.com
论坛
独立开发
进阶教程
【TA】【ESS】07 类的多态性
顶部