Method | Example Code | Output |
---|---|---|
For Loop | <% for i in 0..9 %> Result: <%= i %>, <% end %> | Result: 0,1,2,3,4,5,6,7,8,9 |
<% @people = Person.find(:all) %> <% for i in 0...@person.length %> Result: <%= @person[i].name %>, <% end %> | Result: John,Peter,Sharon | |
<% @people = Person.find(:all) %> <% for person in @people %> Result: <%= @person.name %>, <% end %> | Result: John,Peter,Sharon | |
While Loop | <% i = 0 %> <% while( i < 10 ) %> Result: <%= i %>, <% i+= 1 %> <% end %> | Result: 0,1,2,3,4,5,6,7,8,9 |
Do While Loop | <% i = 5 %> <% begin %> Result: <%= i %>, <% i+= 1 %> <% end while( i < 10 ) %> | Result: 5,6,7,8,9 |
Switch Statement | <% foo = 5 %> <% case foo %> <% when 1 %> Foo is equal to 1 <% when 2..9 %> Foo is between 2 and 9 <% when 10 %> Foo is equal to 10 <% end %> | Foo is between 2 and 9 |
Wednesday, October 14, 2009
Ruby on Rails : For / While / Do While / Switch
Subscribe to:
Post Comments (Atom)
This is an amazing blog,it gives very helpful messages to us.Besides that Wisen has established as Best Javascript Training in Chennai . or learn thru JavaScript Online Training India. Nowadays JavaScript has tons of job opportunities on various vertical industry
ReplyDeleteAfter reading this blog i very strong in this topics and this blog really helpful to all... explanation are very clear so very easy to understand... thanks a lot for sharing this blog.get more info..Ruby on Rails Online Training
ReplyDeleteThis is good site and nice point of view.I learnt lots of useful information.
ReplyDeletepython Training institute in Pune
python Training institute in Chennai
python Training institute in Bangalore
This is a terrific article, and that I would really like additional info if you have got any. I’m fascinated with this subject and your post has been one among the simplest I actually have read.
ReplyDeleteData Science Tutorial
Data Science training in anna nagar
Data science training in jaya nagar
Data science training in pune
Data Science Training in Marathahalli
Data science training in kalyan nagar
This is a terrific article, and that I would really like additional info if you have got any ruby on rails online course
ReplyDeleteWonderful blog.. Thanks for sharing informative blog.. its very useful to me..
ReplyDeleteaws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore
Really it was an awesome article,very interesting to read.You have provided an nice article,Thanks for sharing.
ReplyDeleteaws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore
Really it was an awesome article,very interesting to read.You have provided an nice article,Thanks for sharing.
ReplyDeleteaws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore
Thanks for this wonderful blog it is really informative to all.keep update more information about this
ReplyDeleteaws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore
görüntülüshow
ReplyDeleteücretli show
OCM6
شركة مكافحة الصراصير بالدمام xFSwUelmta
ReplyDelete