Ruby Learning--String--1

Source: Internet
Author: User

#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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.