Say I have a function that checks whether some operation is applicable to an instance of A and, if so, returns an instance of B or None:
Suppose I\'m writing a GUI class Kitteh (val age: Int) { require (age < 5) def saveMeow(file: File) = { /* implementation */ }
When I was writing my recent answer I also tried to solve the problem in more \"functional\" way, but stuck with the following problem:
I have a Scala helper method that currently tries to fetch a URL and return an Option[String] with the HTML of that webpage.
I have read the blog post recommended me here. Now I wonder what some those methods are useful for. Can you show e开发者_开发知识库xamples of using forall (as opposed to foreach) and toList of Option?
I wonder if the standard library is completely null-free and - if not 开发者_高级运维- would be interested what reasonable use-cases exist where returning null is preferable to returning some Option i
I wonder wh开发者_StackOverflow社区y scala.Option doesn\'t have a method fold like this defined:
I wonder what is the reason for the (implicit ev: Null <:< A1) here: sealed abstract class Option[+A] extends Product with Serializable {
I am working on a mixed java/scala pr开发者_开发知识库oject, and I am trying to call a scala object\'s method from Java.This method takes an Option[Double] as a parameter.I thought this would work:
I think I\'m missing something: scala> S开发者_StackOverflow中文版ome(1) collect ({ case n if n > 0 => n + 1; case _ => 0})