object_id一个Fixnum是奇数:
i=0; i += 1 while i.object_id.odd?
# ^CIRB::Abort: abort then interrupt!
i # => 495394962
Run Code Online (Sandbox Code Playgroud)
而似乎object_id任何其他对象的是偶数(Bignum包括):
{}.object_id # => 70230978908220
true.object_id # => 20
false.object_id # => 0
nil.object_id # => 8
/regexp/.object_id # => 70230978711620
:symbol.object_id # => 391528
{/regexp/mou => Struct.new(:hello)}.object_id # => 70230987100840
Run Code Online (Sandbox Code Playgroud)
这是否与Ruby解释器中的一些模糊优化有关?
我试图使用Int32库编写一些代码,但我遇到了类型错误:
let x : int = 7;
Int32.abs(x)
This has type:
int
But somewhere wanted:
int32
Run Code Online (Sandbox Code Playgroud)
我对此感到有些惊讶,因为在其他语言int中只是一个别名int32.
我的问题是:
Int32.abs但是没有Int.abs,例如)