[#3006] mismatched quotation — "stevan apter" <apter@...>

ruby documentation uses a punctuation convention i've never seen

13 messages 2000/05/27

[ruby-talk:02932] Iterators...

From: h.fulton@...
Date: 2000-05-22 22:53:11 UTC
List: ruby-talk #2932
I find myself wishing for something that 
may not exist (but perhaps should?).

In an abitrary iterator, I want to know
whether I am on the first or last iteration.
For example:

  myarray.each { |x| print "{ " if iter_first?
    print x
    if iter_last?
      print " }\n"
    else
      print ", "
    end
  }


This would print something like:

  { 1, 2, 3, 4, 5 }

OK, it might be fairly easy to fake this for
arrays, but not hashes and other things...

Comments, anyone?


Hal 

In This Thread

Prev Next