This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Synthatic sugar for ()=>T

1 reply
edmondo1984
Joined: 2011-09-14,
User offline. Last seen 28 weeks 3 days ago.
Dear all,Is there any way to express in a simple way a function ()=>T ?
I end up often writing
resultOrErrorMessage(()=>doAction(key)(_.summary))(None);
but I would like to write
resultOrErrorMessage(doAction(key)(_.summary))(None);
where
private def doAction(key: CurveKey)(f: CurveMonitor => String): String = {    monitor(key) match {      case Some(associatedMonitor) => f(associatedMonitor)       case None => "The required curve is not in the current partition, or the currency is not started"    }  }

Thank you for your help
Best Regards
Viktor Klang
Joined: 2008-12-17,
User offline. Last seen 1 year 27 weeks ago.
Re: Synthatic sugar for ()=>T


On Thu, Dec 29, 2011 at 2:15 PM, Edmondo Porcu <edmondo [dot] porcu [at] gmail [dot] com> wrote:
Dear all,Is there any way to express in a simple way a function ()=>T ?
I end up often writing
resultOrErrorMessage(()=>doAction(key)(_.summary))(None);
but I would like to write
resultOrErrorMessage(doAction(key)(_.summary))(None);

use => T instead of () => T in the method signature.
 

where
private def doAction(key: CurveKey)(f: CurveMonitor => String): String = {    monitor(key) match {      case Some(associatedMonitor) => f(associatedMonitor)       case None => "The required curve is not in the current partition, or the currency is not started"    }  }

Thank you for your help
Best Regards



--
Viktor Klang

Akka Tech LeadTypesafe - Enterprise-Grade Scala from the Experts

Twitter: @viktorklang

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland