From: Harry Kakueki Date: 2007-06-12T20:11:29+09:00 Subject: Re: Generate a grid of cells, and give characteristics On 6/12/07, Joop Van den tillaart wrote: > Hi you all I am new to this forum and also quite new to ruby...I have > some PHP knowledge but I'm definitely no pro in programming... > > Now I have a project at school...I will try to explain it as short as > possible... > > I need to generate a grid, let's say of 196 cells (grid of 14x14), I'm > now generating it with an array: > > grid = [1, 2, ..., 195, 196] > > 1. first of all is there a way to somehow automatically generate an > array of following numbers or other characters because when I later on > plan to change the gridsize it would be nice if this can be filled > automatically... > Hi, If you want to use one array like in your example, you can fill it using a range. http://www.rubycentral.com/book/tut_stdtypes.html#S3 grid = (1..196).to_a p grid Is that what you want to do? But you may want to use a 2D array. Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/