Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #2323

Re: Separate new lines from an output

From botp <botpena@gmail.com>
Newsgroups comp.lang.ruby
Subject Re: Separate new lines from an output
Date 2011-04-05 05:02 -0500
Organization Service de news de lacave.net
Message-ID <BANLkTimMMJ1PtQHOcHdM2oCEDiDR3sOtYw@mail.gmail.com> (permalink)
References <d631fa1427d24cffc6f83fbb735b4c84@ruby-forum.com>

Show all headers | View raw


On Tue, Apr 5, 2011 at 5:30 PM, Leo M. <leo.mmcm@gmail.com> wrote:
> I'm trying to make 87 different objects, since if i try to push this
> result into an array, the array.size is always 1.

check the doc.
eg, try

   $ ri Array#"<<"


> How could I have 87
> different objects to push in an array?

many ways.
eg,

a=[]
#=> []
87.times{a<<Object.new}
#=> 87
a.size
#=> 87
a.first(5)
#=> [#<Object:0x937c16c>, #<Object:0x937c158>, #<Object:0x937c144>,
#<Object:0x937c130>, #<Object:0x937c11c>]

best regards -botp

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Separate new lines from an output "Leo M." <leo.mmcm@gmail.com> - 2011-04-05 04:30 -0500
  Re: Separate new lines from an output Robert Klemme <shortcutter@googlemail.com> - 2011-04-05 04:44 -0500
  Re: Separate new lines from an output Haruka YAGNI <hyagni@gmail.com> - 2011-04-05 04:47 -0500
  Re: Separate new lines from an output botp <botpena@gmail.com> - 2011-04-05 05:02 -0500
  Re: Separate new lines from an output "Leo M." <leo.mmcm@gmail.com> - 2011-04-05 05:38 -0500
    Re: Separate new lines from an output Peter Hickman <peterhickman386@googlemail.com> - 2011-04-05 05:59 -0500
      Re: Separate new lines from an output Robert Klemme <shortcutter@googlemail.com> - 2011-04-05 07:54 -0500
        Re: Separate new lines from an output Peter Hickman <peterhickman386@googlemail.com> - 2011-04-05 08:28 -0500
          Re: Separate new lines from an output Peter Hickman <peterhickman386@googlemail.com> - 2011-04-05 08:29 -0500
    Re: Separate new lines from an output Josh Cheek <josh.cheek@gmail.com> - 2011-04-05 06:36 -0500
    Re: Separate new lines from an output Phillip Gawlowski <cmdjackryan@googlemail.com> - 2011-04-05 07:33 -0500
  Re: Separate new lines from an output "Leo M." <leo.mmcm@gmail.com> - 2011-04-05 07:07 -0500

csiph-web