#DefineFrench_string ="il \xc3\xa9tait une fois"long_string= <<Eofhere isa long stringwith many paragraphseofputs long_string.empty?puts long_string.include?"many"puts French_string+long_string#concatenatehash = {Key1:"Val1", Key2:"Val2"}string=""str2=""hash.each{|k,v| String << k.to_s <<" is"<< v <<"\ n"}hash.each{|k,v| STR2 <<"#{k}"<<" is"<<"#{v}"<<"\ n"}puts stringputs str2#Joindata = ['1','2','3']s="'Data.each {|x| s << x <<'and a'}puts S#= "1 and a 2 and a 3 and a"Puts Data.join ('and a')# NumberNumber = 5puts"The number is #{number}." #= "The number is 5."Puts"The number is #{5}." #= "The number is 5."Puts"The number after #{number} is #{number.next}."#= = "The number after 5 is 6."Puts"The number prior to #{number} is #{number-1}."#= = "The number prior to 5 is 4."Puts"We ' re ##{number}!" #= "We ' re #5!"
puts i ' ve set X to #{x = 5; x + = 1}. " # escaping puts " \#{foo} " puts #{foo} # puts" #{foo} "# error because no variable of foo defined.
' Oceania have always been at the war with%s. ' 'Eurasia'# = ' Oceania have always been been at the war with Eurasia. ' 'to 2 decimal places:%.4f' %'zero-padded:%.3d ' % Math::P i
JSP, ASP type
' Erb ' = erb.new%q{chunky <%= food%>"bacon"# = > "Chunky bacon!" " Peanut Butter " # = "Chunky Peanut butter!" Puts Template.result
Ruby Learning--String--1