From: Stefano Crocco Date: 2013-01-12T22:03:12+09:00 Subject: Re: Array methods creating confusions as per their functionalities On Saturday 12 January 2013 Arup Rakshit wrote > Arup Rakshit wrote in post #1092018: > > Can any one just elaborate how the below works in Ruby, by definition > > they are not quite clear. Hope a small code snippet may help to > > understand them at their core,how they works? > > > > > > array.frozen? > > My confusion or knowledge gap here is what the `frozen` means in Ruby > platform with the array? How an array can be `frozen`. The document said > only what the functions does in reality. which is "Return true if this > array is frozen (or temporarily frozen while being sorted)." . But this > is for me not enough to understand why Ruby brought the "frozen" > concept. How and what scenarios made an array as frozen array in ruby? > here is the pain. I hope that anyone of this forum will help me out to > clear the logic within me. > > > Thanks! > > -- > Posted via http://www.ruby-forum.com/. A frozen object is an object which can't be modified. You freeze an object using its freeze method. To see an example, run the following code: a=[1,2,3] a.delete_at 1 p a b=[1,2,3] b.freeze b.delete_at 1 You'll see that, while a.delete_at 1 changes the array, b.delete_at 1 raises an exception, because b had been frozen and therefore it can't be modified. According to the questions you're posting, it seems to me you haven't read a comprehensive ruby book. Have you tried the online version of Programming Ruby (http://docs.ruby-doc.com/docs/ProgrammingRuby/)? It free and, even if written for an old version of ruby, most of it is still accurate. I hope this helps Stefano