To sym

symbol to string
intern
to_sym

1 Ruby[ | ]

Ruby
Copy
str = "hello"
my_symbol = str.to_sym
puts my_symbol.class
# Symbol
puts my_symbol
# hello
Ruby
Copy
str = "hello"
my_symbol = str.intern
puts my_symbol.class
# Symbol
puts my_symbol
# hello

2 같이 보기[ | ]