Skip to content

Instantly share code, notes, and snippets.

View kbs4674's full-sized avatar

CHUL MIN, KIM kbs4674

View GitHub Profile

Ruby

  1. symbol과 string의 차이는 무엇인가요?
  • symbol은 한번 정해진 값에 대해선 바꿀 수 없으나, (그렇다고, symbol로 초기화된 변수를 아예 건들지 못하는건 아님, :other_symbol과 같이다른 symbol 혹은 type으로 덮어쓰기가 가능) string은 중간에 내용을 바꿀 수 있다는 차이점이 있음.
a = :something_symbol
=> :something_symbol
a += "hello, world"
NoMethodError: undefined method `+' for :something_symbol:Symbol
a = :other_symbol