2013-05-01から1ヶ月間の記事一覧

Programming Ruby Object

#Object #string t copyed from string s s="Ruby" t=s p t #=>"Ruby" s="Rails" p t #=>"Ruby" p s #=>"Rails" t[-1]="" print s #=>Rails puts "\n" print t #=>Rubo="test" o.class o.class.superclass o.class.superclass.superclass if o.class==String…

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" enda="a".."c" a.each{|l| print "#{l}"} #abc puts "\n" a.step(2){|l| print "#{l}"} #=>ac put…

Programming Ruby Hashes

#hashes numbers=Hash.new numbers["one"]=1 numbers["two"]=2 numbers["three"]=3sum=numbers["one"]+numbers["two"]+numbers["three"] puts summembers={"one"=>1,"two"=>2,"three"=>3} p members members={:one=>1,:two=>2,:three=>3} p membersreturn {"…