LoginSignup
0
0

More than 5 years have passed since last update.

シンボルについて

Last updated at Posted at 2015-06-13

クォートで囲った文字列と同じ意味

1つ目の記法 シングルクオートが前の場合は"文字列"

: hoge = "hoge"

2つ目の記法 ハッシュでの記法
hoge = { :name => "yamada taro", :email => "yamada@example.com"}

{ name: "yamadataro", email: "yamada@example.com"}


Railsでは文字列よりもシンボルを使用する方が普通です。
シンボルは文字列と似ていますが、 クォートで囲む代わりに
コロンが前に置かれている
点が異なります。
たとえば、 :nameはシンボルです。もちろん、余計なことを一切考えずに、 シンボルを単なる文字列とみなしても構いません。

0
0
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
0