"Martin DeMello" <martindemello / yahoo.com> schrieb im Newsbeitrag
news:jfXNd.318521$6l.10705 / pd7tw2no...
> Robert Klemme <bob.news / gmx.net> wrote:
> >
> > Note though that you might as well treat the *first* element
specially.
> > IMHO that's usually easier even with #each:
> >
> > first = true
> > enum.each do |e|
> >   if first
> >     first = false
> >   else
> >     print " -- "
> >   end
> >   print e
> > end
> > print "\n"
>
> Though I hate doing this, because that 'if', that you know is going to
be
> useless after the first time, is nonetheless run for every subsequent
> element. I guess in terms of actually running time it's negligible, but
> it still feels ugly.

Yes, totally agree.  I just wanted to show a more readable solution than
the #inject variants to show that treating the first element specially
might be easier or at least as easy as treating the last element
specially.

Kind regards

    robert