<Ruby> Basics

Source: Internet
Author: User

1.

" 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 of 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! =beginwell,i am amultiple linecomment! =end

4.

Variable_name = Gets.chomp

gets is the Ruby method, which gets the 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 would work fine without chomp, and you'll get extra blank lines everywhere.)

getsIs the Ruby method thatgetsinput from the user. When getting input, Ruby automatically adds a blank line (orNewLine) after each bit of input; chompremoves that extra line. (Your program would work fine withoutchomp, but you'll get extra blank lines everywhere.)

<Ruby> Basics

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.