Without Book Interview Questions and Answers | Online Test | Moct Test
Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Institute Training Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

Ruby On Rails Interview Questions and Answers

Ques. What is Range?
Ans.

Range is a great way to declare continuous variables. You should use it to declare arrays and other types of collections. 

range1 = (1..4).to_a
 => [1, 2, 3, 4] 
puts range1
1
2
3
4

You can also create strings in this format and it fills in the interim values automatically.

range2 = ('bar'..'bat').to_a
puts range2
bar
bas
bat
Since the end result of using range is an array you can also iterate over it just like any other array.
range2.each do |str|
   puts "In Loop #{str}"
end

This produces the result as shown below:

In Loop bar
In Loop bas
In Loop bat
Is it helpful? Yes No

Most helpful rated by users:

©2016 WithoutBook