From 10ab89ae44718e30bc1688f1a73a66cbd7dd333c Mon Sep 17 00:00:00 2001 From: buraq Date: Fri, 23 Jan 2004 11:19:52 +0000 Subject: more --- doc/faq/faq.xml | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'doc/faq') diff --git a/doc/faq/faq.xml b/doc/faq/faq.xml index b24f4bc18f..193bba12ed 100644 --- a/doc/faq/faq.xml +++ b/doc/faq/faq.xml @@ -87,6 +87,44 @@ if you prefer this. +
+ + + What is the "standard" way to write a simple loop in +Scala? + + for (val i <- Iterator.range(1,1000000) + +or + + var i = 1; + while (i<=1000000){ ...; i=i+1; } + + + +Both are fine, but in the current implementation the second one should be more efficient. + + + +how can I catch exceptions in Scala? + + You have to use standard pattern matching here (Java's +"catch" clauses are really nothing more than a limited form of pattern +matching). + + + try { + ... + } catch { + case e: Exception => ... + case e:IOException => ... + } + + + + +
+ @@ -128,7 +166,14 @@ can access methods, fields (even if they are static), etc. -
+
+ +I want to use the Ord interface to handle Double, Int, and Char. Why doesn't it work ? + +Currently, the class scala.Double (and all other value classes) are +*not* a subclass of scala.Ord. This is an implementation restriction +of our compiler. +