. View this ad or post your own Ruby Job!

Sunday, November 06, 2005

Writing One's Own Methods in Ruby

What have I found out so far?
  • Definition of Ruby
  • Ruby Windows Installer
  • Interactive Ruby - Open a new DOS window and type irb --simple-prompt A prompt appears as >>
  • Run a Ruby program by typing ruby hello.rb
  • Learnt some features of Ruby like comments, naming rules, variables, constants, strings etc.
  • Various Text Editors/IDEs like SciTE, NotePad2
  • Constructs like the if else and while
  • Some methods in Ruby.
  • Arrays

Today, I am going to look at writing one's own methods in Ruby.

Let us look at a simple program.
# A simple method
def hello
puts 'Hello'
end
#use the method
hello
# Method with an argument
def hello1(name)
puts 'Hello ' + name
return 'success'
end
result = hello1('satish')
# Check the return value
puts result


First Post | Previous | Next



Technorati Tags:
Blogs linking to this article

0 Comments:

Post a Comment

<< Home

Valid XHTML 1.0!