0
1

More than 3 years have passed since last update.

シンボルと%記法

Posted at

%s

シンボルの作成

ruby
%s!i love soccer!  
%(i love soccer)
#=> :"i love soccer"

%i

シンボルの配列を作成

ruby
%i(soccer baseball basketball)   #=>  [:soccer, :baseball, :basketball]

to_sym & to_s

シンボル化と文字列化

ruby
string = 'soccer'
string.to_sym  #=>  :soccer

symbol = :baseball
symbol.to_s  #=>  "baseball"
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1