Symbol#inspect():inspect()是Symbol類方法,它返回符號值的字符串表示形式。
用法:Symbol.inspect()
參數:符號值
返回:符號值的字符串表示形式。
示例1:
# Ruby code for Symbol.inspect() method
# declaring Symbol
a = :aBcDeF
# declaring Symbol
b = :"\u{e4 f6 fc}"
# declaring Symbol
c = :ABCDEF
# inspect form
puts "Symbol a inspect form : #{a.inspect}\n\n"
puts "Symbol b inspect form : #{b.inspect}\n\n"
puts "Symbol c inspect form : #{c.inspect}\n\n"
輸出:
Symbol a inspect form : :aBcDeF Symbol b inspect form : :"\u00E4\u00F6\u00FC" Symbol c inspect form : :ABCDEF
示例2:
# Ruby code for Symbol.inspect() method
# declaring Symbol
a = :geeks
# declaring Symbol
b = :"\u{e5 f6 f3}"
# declaring Symbol
c = :GEEKS
# inspect form
puts "Symbol a inspect form : #{a.inspect}\n\n"
puts "Symbol b inspect form : #{b.inspect}\n\n"
puts "Symbol c inspect form : #{c.inspect}\n\n"
輸出:
Symbol a inspect form : :geeks Symbol b inspect form : :"\u00E5\u00F6\u00F3" Symbol c inspect form : :GEEKS
相關用法
- Ruby Rational inspect()用法及代碼示例
- Ruby Range inspect()用法及代碼示例
- Ruby Regexp inspect()用法及代碼示例
- Ruby Time inspect用法及代碼示例
- Ruby Struct inspect()用法及代碼示例
- Ruby Hash inspect()用法及代碼示例
- Ruby StringScanner inspect用法及代碼示例
- Ruby Array class inspect()用法及代碼示例
- Scala Symbol =~用法及代碼示例
- Scala Symbol ===用法及代碼示例
- Scala Symbol ==用法及代碼示例
- Ruby Symbol next用法及代碼示例
- Ruby Symbol swapcase用法及代碼示例
- Ruby Symbol to_proc用法及代碼示例
- Ruby Symbol to_sym用法及代碼示例
注:本文由純淨天空篩選整理自mayank5326大神的英文原創作品 Ruby | Symbol inspect function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。