- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Synthatic sugar for ()=>T
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
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










Re: Synthatic sugar for ()=>T
On Thu, Dec 29, 2011 at 2:15 PM, Edmondo Porcu <edmondo [dot] porcu [at] gmail [dot] com> wrote:
use => T instead of () => T in the method signature.
--
Viktor Klang
Akka Tech LeadTypesafe - Enterprise-Grade Scala from the Experts
Twitter: @viktorklang