From: Robert Klemme Date: 2011-08-01T05:58:53+09:00 Subject: Re: A question on style... On Sun, Jul 31, 2011 at 10:06 PM, Joseph Phillips wrote: > Hi everyone, > > Long time developer here, new to Ruby. > > I have a simple, single file Ruby program that randomly chooses a response to input text. I have a method to return the the array of responses, which I call further into the file in my main routine. This is the method: > > def get_responses >     [ >         "Got it.", >         "Interesting. I've made a note of that.", >         "Noted.", >         "Right.", >         "I see.", >         "As you say." >     ] > end > > Is this conventional? Is there any benefit in late acquisition of this array, or would it be normal to just assign it to a variable up front? I find it inelegant to recreate a constant over and over again. It's also inefficient. Better assign to a instance variable, global var or even constant. Note also that you can use Array#sample for automated picking of a random element. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/