Roshan Book

My Tech Notebook

Learning Ruby Part 11 Looping


4.times {puts “manish”} – > prints manish 4 times

3.upto<7> {puts “manish”} – > Prints manish counting 3 to 7

15.downto<12>{puts “manish”} – > Prints manish from 15 upto 12. That is 4 times

0.step<15,5> {puts “manish”} – > Prints  manish 4 times. It steps by 5 , rather than 1. Counting starts from 0

1.upto<10> {|variable| puts variable} –> It prints the value inside variable and print it out like

1

2

3 to 10

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: