Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

best ruby cheat sheet

:symbol # symbol is like an ID in html. :Symbols != "Symbols"
# Symbols are often used as Hash keys or referencing method names.
# They can not be changed once created. They save memory (only one copy at a given time). Faster.
:test.to_s # converts to "test"
"test".to_sym # converts to :test
"test".intern # :test
# Symbols can be used like this as well:
my_hash = { key: "value", key2: "value" } # is equal to { :key => "value", :key2 => "value" }
Source by github.com #
 
PREVIOUS NEXT
Tagged: #ruby #cheat #sheet
ADD COMMENT
Topic
Name
9+4 =