diff options
author | buraq <buraq@epfl.ch> | 2004-01-23 11:19:52 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2004-01-23 11:19:52 +0000 |
commit | 10ab89ae44718e30bc1688f1a73a66cbd7dd333c (patch) | |
tree | 63dcee5480e42a3e96abbdc3ebedbb4772fc3109 | |
parent | 24c538e6348cb42091440b751f7cbe330b0495ab (diff) | |
download | scala-10ab89ae44718e30bc1688f1a73a66cbd7dd333c.tar.gz scala-10ab89ae44718e30bc1688f1a73a66cbd7dd333c.tar.bz2 scala-10ab89ae44718e30bc1688f1a73a66cbd7dd333c.zip |
more
-rw-r--r-- | doc/faq/faq.xml | 47 |
1 files changed, 46 insertions, 1 deletions
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. </answer> </entry> </section> + <section title="Programming"> + <entry> + <question> + What is the "standard" way to write a simple loop in +Scala? +<code> + for (val i <- Iterator.range(1,1000000) +</code> +or +<code> + var i = 1; + while (i<=1000000){ ...; i=i+1; } +</code> +</question> +<answer> +Both are fine, but in the current implementation the second one should be more efficient. </answer> + </entry> + +<entry> +<question>how can I catch exceptions in Scala?</question> + +<answer> You have to use standard pattern matching here (Java's +"catch" clauses are really nothing more than a limited form of pattern +matching). + +<code> + try { + ... + } catch { + case e: Exception => ... + case e:IOException => ... + } +</code> +</answer> +</entry> + + </section> + <!-- zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz --> @@ -128,7 +166,14 @@ can access methods, fields (even if they are static), etc. <!-- Less General --> <!-- zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz --> - <section title="Less General"> + <section title="Limitations"> +<entry> +<question>I want to use the Ord interface to handle Double, Int, and Char. Why doesn't it work ?</question> + +<answer>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. </answer> +</entry> <!-- <entry> <question>What were the first reactions when you released your language ?</question> |