Symbol#intern():intern()是Symbol類方法,它返回與symbol相對應的對象。
用法:Symbol.intern()
參數:符號值
返回:與符號對應的對象
示例1:
# Ruby code for Symbol.intern() method
# declaring Symbol
a = :aBcDeF
# declaring Symbol
b = :"\u{e4 f6 fc}"
# declaring Symbol
c = :ABCDEF
# intern form
puts "Symbol a intern form : #{a.intern}\n\n"
puts "Symbol b intern form : #{b.intern}\n\n"
puts "Symbol c intern form : #{c.intern}\n\n"
輸出:
Symbol a intern form : aBcDeF Symbol b intern form : äöü Symbol c intern form : ABCDEF
示例2:
# Ruby code for Symbol.intern() method
# declaring Symbol
a = :geeks
# declaring Symbol
b = :"\u{e5 f6 f3}"
# declaring Symbol
c = :GEEKS
# intern form
puts "Symbol a intern form : #{a.intern}\n\n"
puts "Symbol b intern form : #{b.intern}\n\n"
puts "Symbol c intern form : #{c.intern}\n\n"
輸出:
Symbol a intern form : geeks Symbol b intern form : åöó Symbol c intern form : GEEKS
相關用法
- Scala Symbol ===用法及代碼示例
- Scala Symbol ==用法及代碼示例
- Scala Symbol =~用法及代碼示例
- Ruby Symbol next用法及代碼示例
- Ruby Symbol encoding用法及代碼示例
- Ruby Symbol to_sym用法及代碼示例
- Ruby Symbol to_proc用法及代碼示例
- Ruby Symbol upcase用法及代碼示例
- Ruby Symbol inspect用法及代碼示例
- Ruby Symbol id2name用法及代碼示例
- Ruby Symbol capitalize用法及代碼示例
- Ruby Symbol casecmp用法及代碼示例
- Ruby Symbol empty?用法及代碼示例
- Ruby Symbol length用法及代碼示例
- Ruby Symbol succ用法及代碼示例
注:本文由純淨天空篩選整理自mayank5326大神的英文原創作品 Ruby | Symbol intern function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。