Programming Ruby Range

#Range
cold_war=1946..1986
birthday_year=1974
if cold_war.include? birthday_year
puts "include birthday_year"
else
puts "not include birthday_year"
end

a="a".."c"
a.each{|l| print "#{l}"} #abc
puts "\n"
a.step(2){|l| print "#{l}"} #=>ac
puts "\n"
puts a.to_a #=>["a", "b", "c"]

s="abc123"
puts s.succ #=>abc124

#p 1..3.to_a #error
p (1..3).to_a

x=1...5
x.each {|a| puts a}


#symbles
:symbol #A symble literal
:"symbol" #The same literal
:'another long symbol' #Quate are useful symbol with spaces
s="string"
sym=:"#{s}"
puts sym #=>string


str="string" #begin with a string
sym=str.intern #convert to a symbol
sym=str.to_sym #another way to do the same thing
str=sym.to_s #convert back to a string
str=sym.id2name #another way to do it