It looks like you're doing a connect four program. I would probably create
a class Column that I can drop things in like a bucket with 7 buckets
(instances) and then have a Row class for the lines.. Your Column class
would have to inherit from Array and you'd be using #unshift and #pop.
There are several ways to do it, because it doesn't really need to be a
reverse escalator, but that's what I'd do.

On Sat, Dec 20, 2014 at 9:50 AM, Abinoam Jr. <abinoam / gmail.com> wrote:

> Hi Troy,
>
> The code you showed in the previous e-mail is different.
>
> > fourth array
> > my_array = [3, -, X, X, X]
>
> With this initialization you're getting cols and lines swapped
> compared to the previous example.
>
> > @board    = Array.new(6, Array.new(7, "-))
> > @header   = Array("1".."7)
>
> Keep in mind that with this initialization above you will transverse
> the array like this.
>
> @board[line][column]
>
> For something like this:
> 1 2 3 4 5 6 7
> - - - - - - -
> - - - - - - -
> - - - - - - -
> - - - - - - -
> - - - - - - -
> - - x - - - -
>
> @board[0] # for example
> # => ["1", "2", "3", "4", "5", "6", "7"]
>
> @board[6]
> # => [ "-", "-", "x", "-", "-", "-", "-" ]
>
> @board[6][2] # line 6, col 2
> # => "x"
>
> @board[6][1] # line 6, col 1
> # => "-"
>
> # Not like the 'my_array' example
> my_array = [3, -, X, X, X]
>
> Where the Array has one column.
>
> So, you're probably willing to loop in reverse from the last _line_
> (6) to the second one (1) (because the first line (0) is the header).
> While looping, testing the desired column (that column chosen by the
> user), for example column 2 (the third one) to see if it has an "x".
> If not, you should change it to an "x" and break the loop.
> It yes, it has an "x", you should try to loop again, testing the line
> before the current line (line-1) and go until line 1 (the second line;
> the line after the header).
>
> Is it something like "Conect Four" ? (
> http://en.wikipedia.org/wiki/Connect_Four)
>
> It's not hard and I think you're getting closer.
> If you get stuck and need more help just drop another e-mail on this
> thread.
>
> Abinoam Jr.
>
> On Sat, Dec 20, 2014 at 12:36 AM, Troy Leach <troyleach29 / gmail.com>
> wrote:
> > Ok..if I under stand here is snippets of the full array (sorry I havent
> > loaded this up to git or I could show all my code but its a bit of a
> mess
> > right now)
> >
> > this is my array
> >
> > @board    = Array.new(6, Array.new(7, "-))
> > @header   = Array("1".."7)
> >
> > board.unshift(header)
> >
> > => produces
> > 1 2 3 4 5 6 7
> > - - - - - - -
> > - - - - - - -
> > - - - - - - -
> > - - - - - - -
> > - - - - - - -
> > - - - - - - -
> >
> > => select a column to drop a game piece
> > => user input == 3
> >
> > after the user input the new board would look like this
> >
> > 1 2 3 4 5 6 7
> > - - - - - - -
> > - - - - - - -
> > - - - - - - -
> > - - - - - - -
> > - - - - - - -
> > - - x - - - -
> >
> > is this better?
> >
> > On Dec 19, 2014, at 9:29 PM, Jorge Colon <2upmedia / gmail.com> wrote:
> >
> > Hi Troy,
> >
> > Could you add how you'd expect the array to look like and how you would
> not?
> > Perhaps throw in some different scenarios if that applies?
> >
> > Regards,
> >
> > Jorge Colon
> > Senior Software Architect/Owner
> > 2UP Media
> >
> > Zend Certified Engineer
> > www.bit.ly/jorgecolonzce
> >
> > Sent from my mobile device
> >
> > On Dec 19, 2014, at 10:27 PM, Troy Leach <troyleach29 / gmail.com> wrote:
> >
> > sorry to be vague...
> > I tried what you suggested. It didnt work for me.
> >
> > starting array
> > my_array = [3, -, -, -, -]
> >
> > second array
> >
> > my_array = [3, -, -, -, X]
> >
> > third array
> > my_array = [3, -, -, X, X]
> >
> > fourth array
> > my_array = [3, -, X, X, X]
> >
> > what im trying to do is basically make a game. I want the userto pick
> > row  3 to put a game piece in so I need to see if thegame piece
> already
> > exist or not. if it doesnt insert a game piece if it does check the next
> > empty spot to see if the game piece exist there if it doesnt insert a
> game
> > piece if it does move onto the next and so on make sense..
> >
> > I really want to try and write the code myself but I have been struggling
> > with this one piece for two days make sense?
> >
> >
> >
> > On Dec 19, 2014, at 9:17 PM, Raj Sahae <rajsahae / gmail.com> wrote:
> >
> > The question is a bit vague. Are you just trying to iterate through the
> > array in reverse? Can you give an example input and output?
> >
> > I was originally going to just say something like
> >
> > my_array.reverse.map{|n| n == - ? X : n}.reverse
> >
> > Its not the most efficient way, it would be better to just iterate from
> > behind once, but does that do what you want or are you looking for
> different
> > output?
> >
> > 
> > Sent from Mailbox
> >
> >
> > On Fri, Dec 19, 2014 at 7:07 PM, Troy Leach <troyleach29 / gmail.com>
> wrote:
> >>
> >> Hello all,
> >> first time posting, or emailing as it may be.
> >> Im a newbie to Ruby and I am struggling with something that seems very
> >> very simple to me but no matter what I try it I cant get my desired out
> >> put. (therefore I guess it isnt easy.)
> >>
> >> I want to iterate through my_array to see if the last element is == -
> if
> >> it is replace that element with X
> >>
> >> Then I want to repeat this operation.
> >> I want to iterate through my_array to see if the last element is == to
> -
> >> NO
> >> move to the next to last element, is this element == to - YES replace
> >> with X"
> >>
> >> I know how to make them ALL change at once but that isnt my goal, it
> >> needs to be one at time. Example would be receiving user input so I
> would
> >> want to change the elements one at a time. Kind of like a match data.
> >>
> >> starting array
> >> my_array = [3, -, -, -, -]
> >>
> >> Hope this makes sense and thanks in advance for any help!
> >>
> >> Troy
> >>
> >>
> >
> >
> >
>