首页 > 其他 > 详细

Ruby intro

时间:2014-11-16 07:05:10      阅读:257      评论:0      收藏:0      [点我收藏+]

1. input

print "What‘s your first name?"
first_name = gets.chomp

  chomp will delete "\n" from the string

http://www.ruby-doc.org/docs/Tutorial/part_02/user_input.html

 

2. output

with format #{variable_name}

first_name = "Kevin"
puts "Your name is #{first_name}!"

 

city = gets.chomp  
puts "The city is " + city  

 

3. exclaimation mark !

  make value contain in the variable itself

state.upcase!

same as

state=state.upcase

 

Ruby intro

原文:http://www.cnblogs.com/phoenix13suns/p/4100956.html

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