This is a discussion on Ruby Datastructure within the Ruby forums, part of the Web Development category; Hi, Can any one explain about Ruby Datastructure?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Data structures is a generalized name for arrays,hashes,string Data structures have been invented because simple variables are not enough for solving more complex problems. Methods are give other names too, such as functions,subprograms or procedures, while in other programming languages there might be several differences between all these, they all mean pretty much the same thing in Ruby, although everyone is trying to using the term "method" only. Here's how you define a method: def mymethod puts "this is my first method" end |
| |||
| call a method (when you call a method Ruby executes the statements in the method): by giving it's name: mymethod pass arguments to a method def showme(message) puts message end message="ruby says hello" showme(message)
__________________ Shaalini.S ![]() Be the Best of Whatever you are... |
| |||
| Return multiple values with a method def showme() return “Thank”, “you” end array = showme puts array.join(“ “) showme if you want the text to be displayed with spaces between words, assign an array to the method and use the join method on the array.
__________________ Shaalini.S ![]() Be the Best of Whatever you are... |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What Is RUBY? | theseokit | Ruby | 10 | 09-25-2008 02:22 AM |
| Is Ruby for Web? | S.Vinothkumar | Ruby | 6 | 11-20-2007 01:25 AM |
| Ruby within .NET? | econwriter5 | Ruby | 0 | 03-07-2007 05:02 PM |
| Ruby IDE | drecko | Ruby | 0 | 02-16-2007 12:11 AM |