The Artima Developer Community
Sponsored Link

Akka Concurrency Forum
Import for Duration syntactic sugar

1 reply on 1 page. Most recent reply: Nov 30, 2012 8:09 AM by Derek Wyatt

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 1 reply on 1 page
Andreas Gies

Posts: 15
Nickname: 84653
Registered: Nov, 2012

Import for Duration syntactic sugar Posted: Nov 30, 2012 7:50 AM
Reply to this message Reply
Advertisement
Hi,

it's probably me having read something and not remembering where it was. I am following the chapters with the examples. There is one minor thing that i seem to be unable to find:

What makes a thing like

1.second

work in the code ? So far i have coded around this with something like

Duration("1 s")

bit it keeps nagging me that I am doing something odd here ...

Thx and best regards
Andreas


Derek Wyatt

Posts: 69
Nickname: dwyatt
Registered: Oct, 2012

Re: Import for Duration syntactic sugar Posted: Nov 30, 2012 8:09 AM
Reply to this message Reply
Unfortunately this was something that changed in Scala very quickly after the release of the book.

It depends on what version of Scala you're using, but with 2.10.0-RC3, it would be this:


import scala.concurrent.duration._

val oneSecond = 1.second
// returns a scala.concurrent.duration.FiniteDuration

Flat View: This topic has 1 reply on 1 page
Topic: On traits vs. Params Previous Topic   Next Topic Topic: Ch 8: Page 195

Sponsored Links



Google
  Web Artima.com   

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