I literally sighed when I read this about REXML, the XML parser for Ruby:
Some of the common differences are that the Ruby API relies on block enumerations, rather than iterators. For example, the Java code:
for (Enumeration e=parent.getChildren(); e.hasMoreElements(); ) { Element child = (Element)e.nextElement(); // Do something with child }In Ruby beccomes
parent.each_child{ |child| # Do something with child }
Advertisement
0 Responses to “Selah”