Methods in Ruby on rails

By: Brian Marick Emailed: 1696 times Printed: 2203 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

Ruby methods let you create new verbs (messages) in the Ruby lan- methods guage. It’s a bit confusing that two closely related ideas—messages and methods—have such similar names. 

Delimiting Blocks

Blocks can start with a do and end with end, or they can start with { and end with }. The following two snippets of code mean the same thing:

array.each do | element |

puts element

end

array.each { | element |

puts element

}

My sense is that Rubyists prefer the first except for short blocks, especially those that can fit on one line:

array.each { | element | puts element }


Ruby Home | All Ruby Tutorials | Latest Ruby Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Brian Marick
The Question Mark Operator in Ruby on rails
unless in Ruby on rails
if . . . elsif . . . else in Ruby on rails
Methods in Ruby on rails
Command-line Arguments in Ruby on rails
Naming conventions in Ruby on rails

More Tutorials in Ruby
Standard Library Packages in Ruby
Module Abbrev in Ruby
encoding and decoding in Ruby using Base64 Module
Benchmark module in Ruby
benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) {|report| ...} in Ruby
bm(label_width = 0, *labels) {|report| ...} in Ruby
bmbm(width = 0) {|job| ...} in Ruby
CGI class in Ruby
URL encode a string in Ruby
escapeElement() in Ruby
escapeHTML() in Ruby
new(type = "query") in Ruby
parse(query) in Ruby
pretty() in Ruby
Format a Time object as a String in Ruby

More Latest News
Most Viewed Articles (in Ruby )
URL decode a string in Ruby
Sending emails and Receiving emails using Ruby On rails
Methods in Ruby on rails
if . . . elsif . . . else in Ruby on rails
pretty() in Ruby
Naming conventions in Ruby on rails
The Question Mark Operator in Ruby on rails
Standard Library Packages in Ruby
Module Abbrev in Ruby
bm(label_width = 0, *labels) {|report| ...} in Ruby
URL encode a string in Ruby
escapeElement() in Ruby
escapeHTML() in Ruby
parse(query) in Ruby
out() in Ruby
Most Emailed Articles (in Ruby)
parse(query) in Ruby
POST a form in Ruby
IMAP in Ruby
Sending emails using SMTP in Ruby
Defining tables and classes (using MySQL) in Ruby on Rails
Action Pack - Ruby On rails from request to response
Getting started with Ruby on rails
Prompts, Command Lines, Prompts, and irb in Ruby on rails
unless in Ruby on rails
escapeHTML() in Ruby
new(type = "query") in Ruby
date and time in Ruby
SimpleDelegator in Ruby
Reading URL content using Ruby (HTTP)
Naming conventions in Ruby on rails