亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Ruby中為何要同時有to_s,to_str,inspect這三個函數(shù)?nil.inspect為何是“nil”
怪我咯
怪我咯 2017-04-24 09:09:51
0
2
816

ruby新手,求大俠指點一二。

怪我咯
怪我咯

走同樣的路,發(fā)現(xiàn)不同的人生

reply all(2)
Ty80

First question:
to_s should be a widely existing method, and to_str should be String or a method that only a few classes have. Ruby does have many methods, https://ruby-china.org/topics/25311.

Second question:
The return type of inspect is string, which returns a human-readable representation of the current object. nil.inpsect returns "nil" 因為他就是返回 "nil", just look at the NilClass#inspect documentation.

劉奇

A problem needs to be pointed out here, that is, nil跟其他語言中的null是不一樣的,nil in Ruby is an object (not a class, it is an object of the NilClass class). This object is used in Ruby to represent without anything, but it is an object in itself .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template