The Artima Developer Community
Sponsored Link

Agile Buzz Forum
More on Smalltalk Productivity

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
More on Smalltalk Productivity Posted: Sep 29, 2003 12:38 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: More on Smalltalk Productivity
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement
Along the lines of this post, a reader submits this example:

Problem: I have a list of objects. I want to create another list containing the 'id' property of those objects.

Solutions:

Ruby


     list.map { |i| i.id }

Java


     List ids = new ArrayList();for (Iterator i = list.iterator(); i.hasNext(); ) {    ids.add(new Long(((Thingy)i.next()).getId()));}

Java w/ 1.5-style Generics and For Loop
     List ids = new ArrayList();for (Thingy x :list) {    ids.add(new Long(x.getId()));}

And the Smalltalk for that:

list collect: [:each | each id]

I think that all speaks for itself...

Yes, it certainly does. Just in sheer time at the keyboard, Java loses...

Read: More on Smalltalk Productivity

Topic: Weather via RSS Previous Topic   Next Topic Topic: Optimization lesson

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use