首页 > 其他 > 详细

Ruby_day[1]控制流2

时间:2014-10-22 21:50:30      阅读:322      评论:0      收藏:0      [点我收藏+]

summary:

  1: puts "s in #{user_input}" 和puts ‘s in #{user_input}‘不同,前者#{user_input}会输出user_input的值,后者只是输出鸳原样,s in #{user_input}

  

 1 print "Thtring, pleathe!: "
 2 user_input = gets.chomp
 3 user_input.downcase!
 4 
 5 if user_input.include? "s"
 6   user_input.gsub!(/s/, "th")
 7 else
 8   puts "Nothing to do here!"
 9 end
10   
11 puts "Your string is: #{user_input}"

 

(As a general rule, Ruby methods that end with ? evaluate to the boolean values true or false.

Ruby_day[1]控制流2

原文:http://www.cnblogs.com/jypwn/p/4044262.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!