From: Martin DeMello Date: 2002-12-11T23:38:19+09:00 Subject: Re: For (i=0;i>....) in Ruby? stefanocheri@freenet.de wrote: > Hello, > > how do i write this C++ source code in ruby: > > cout<<"Enter field length: "; > cin>>Field; puts "Enter field length" max = gets # vars starting with capital letters are constants # plus, you want to input Max, not Field in your C++ code # anyway > for(i=0;i { > cout<<"Insert "< cin>>Field[i]; > } field = [] # or field = Array.new 0.upto(max) {|i| print "Insert #{i}. Number: " # puts adds a newline; print does not field[i] = gets # arrays can be grown dynamically } martin