File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -689,18 +689,20 @@ Abstract `Duration` contains methods that allow :
689
689
For example ` val d = Duration(100, MILLISECONDS) ` .
690
690
3 . By parsing a string that represent a time period. For example ` val d = Duration("1.2 µs") ` .
691
691
692
+ Duration also provides ` unapply ` methods so it can be used in pattern matching constructs.
692
693
Examples:
693
694
694
695
import scala.concurrent.util.Duration
696
+ import scala.concurrent.util.duration._
695
697
import java.util.concurrent.TimeUnit._
696
698
699
+ // instantiation
697
700
val d1 = Duration(100, MILLISECONDS) // from Long and TimeUnit
698
701
val d2 = Duration(100, "millis") // from Long and String
699
702
val d3 = 100 millis // implicitly from Long, Int or Double
700
703
val d4 = Duration("1.2 µs") // from String
701
704
702
- Duration also provides ` unapply ` methods so it can be used in pattern matching constructs as follows:
703
-
705
+ // pattern matching
704
706
val Duration(length, unit) = 5 millis
705
707
706
708
<!--
You can’t perform that action at this time.
0 commit comments