首页 > 其他 > 详细

<Ruby> Basics

时间:2016-09-06 00:54:40      阅读:202      评论:0      收藏:0      [点我收藏+]

1.

puts "Hello"

This write "Hello" to the screen with a new line tailed to.

print "Hello"

Just like puts, but without new line.

 

2.

"You know nothing".length

This output the string length.

"Jon Snow".reverse

"wonS noJ"

"OVERWATCH".downcase #---> "overwatch"
"overwatch".upcase   #---> "OVERWATCH"

Let‘s play Overwatch...

 

3.

# I‘m a single line comment!

=begin
Well,
I am a
multiple line
COMMENT!
=end

 

4.

variable_name = gets.chomp

gets is the Ruby method that gets input from the user. When getting input, Ruby automatically adds a blank line (or newline) after each bit of input; chomp removes that extra line. (Your program will work fine without chomp, but you‘ll get extra blank lines everywhere.)

gets is the Ruby method that getsinput from the user. When getting input, Ruby automatically adds a blank line (or newline) after each bit of input; chomp removes that extra line. (Your program will work fine withoutchomp, but you‘ll get extra blank lines everywhere.)

<Ruby> Basics

原文:http://www.cnblogs.com/mjust/p/5844086.html

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