This is a discussion on how to assign info to a blank array? within the Ruby forums, part of the Web Development category; how to assign info to a blank array...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| how to assign info to a blank array ![]()
__________________ S.VinothkumaR Behind me is infinite power, Before me is Endless Possibility, Around me is Boundless Opportunity, Why should I fear! |
| Sponsored Links |
| |||
| You can either declare an array using Array.new, or assign it to an empty array instance []: Code: words = Array.new Code: words = [] Code: #!/usr/bin/env ruby words = Array.new # Get list of words from the user word = gets.chomp while word != '' words.push word word = gets.chomp end # Sort the array sortedwords = words.sort # Print it out sortedwords.each do |word| puts word end Code: #!/usr/bin/env ruby words = Array.new # Get list of words from the user word = gets.chomp while word != '' words.push word word = gets.chomp end # Sort the array words.sort! # Print it out words.each do |word| puts word end |
| |||
| Hey buddy...! Thanks alot! And also thanks alot for explaining it to me, i really appreciate you spending the time to do it.
__________________ S.VinothkumaR Behind me is infinite power, Before me is Endless Possibility, Around me is Boundless Opportunity, Why should I fear! |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to assign html Content to RichText as a Normal Text? | poornima | ASP and ASP.NET Programming | 3 | 03-10-2008 02:15 AM |
| What’s the difference between the System.Array.CopyTo() and System.Array.Clone() ? | Archer | C# Programming | 2 | 08-25-2007 02:00 AM |
| When to you use $_REQUEST[ ] array in php..? | oxygen | PHP Programming | 2 | 07-30-2007 03:52 AM |
| Array filtering | Jeyaseelansarc | PHP Programming | 1 | 07-17-2007 08:07 AM |
| Paging array in PHP | kingmaker | PHP Programming | 0 | 07-16-2007 10:11 PM |