From: Robert Klemme Date: 2004-10-05T23:54:50+09:00 Subject: Re: String limits? "STEPHEN BECKER I V" schrieb im Newsbeitrag news:3703ec2d04100507177d3aee72@mail.gmail.com... > Does a string have a limited size? assuming running on the average desktop. > > i know > var="a"*1000000 > print var > prints 1million a's, i even try declaring the values around it > var0="a" > var1="b" > var2="c" > var1=var1*1000000 > print var2 Memory is the limit (plus maybe some fixed max int that is allowed for a malloc() call). > and its a c :) but does ruby actively prevent overflow? am i thinking > about this in the wrong way? > Stephen In case of failure you'll see somethig like this: /usr/lib/ruby/1.8/irb.rb:296:in `inspect': failed to allocate memory (NoMemoryError) from /usr/lib/ruby/1.8/irb.rb:296:in `output_value' .... Normally you don't have to worry at all about overflow problems. There are no buffer overflows possible with Ruby strings as there are with C strings (well, C doesn't really have strings - it just has char*). Kind regards robert