📜  红宝石 |符号实习生函数

📅  最后修改于: 2022-05-13 01:55:20.755000             🧑  作者: Mango

红宝石 |符号实习生函数

Symbol#intern() :intern()是一个 Symbol 类方法,它返回对应于 symbol 的对象。

示例 #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