2 Replies - 2153 Views - Last Post: 02 September 2010 - 07:27 PM

#1 Sergio Tapia   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1259
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Old Spice Code

Posted 30 August 2010 - 06:05 AM

*
POPULAR

Taken from CarsonKahn via Forrst:

Ladies: Look at your code.—

. return Iterables.filter( . . . . employees, . . . . new Predicate<Employee>() { . . . . . . public boolean apply(Employee e) { . . . . . . . . return e.isPartTime(); . . . . . . } . . . . });  

Now look at mine.  

. return Iterables.filter(employees, {Employee e -> e.isPartTime()});  

Now back at your code.  

. return Iterables.filter( . . . . employees, . . . . new Predicate<Employee>() { . . . . . . public boolean apply(Employee e) { . . . . . . . . return e.isPartTime(); . . . . . . } . . . . });  

Now back to mine.  

. return Iterables.filter(employees, {Employee e -> e.isPartTime()}); 

Sadly, it isn't mine.  But when it stops using inner-class-scented Java and switches to JDK 7, it could smell like mine.  
Look down. Back up. Where are you? You're in an IDE, with the code your code could smell like. What's in your hand? Back at me. I have it. It's a lambda expression, with two arguments of that type you love.  

Look again: the lambda is now a method reference!  

. return Iterables.filter(employees, Employee#isPartTime);  

Anything is possible when your code smells like fresh new JDK 7 hotness and not inner classes. I'm on a horse. Hurah!



Is This A Good Question/Topic? 6
  • +

Replies To: Old Spice Code

#2 Kilorn   User is offline

  • XNArchitect
  • member icon



Reputation: 1361
  • View blog
  • Posts: 3,534
  • Joined: 03-May 10

Re: Old Spice Code

Posted 30 August 2010 - 06:09 AM

I love those old spice commercials. Definitely a great marketing campaign. This also made me laugh. Good find.
Was This Post Helpful? 0
  • +
  • -

#3 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3213
  • View blog
  • Posts: 19,241
  • Joined: 14-September 07

Re: Old Spice Code

Posted 02 September 2010 - 07:27 PM

This is fantastic.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1