Option...aly bored

I got big on using Option with Some/Null - I thought it's an awesome idea
when I first saw it...now I'm getting bored however.

Isn't it the same as a checked exception, really? It started to either
require x match { case Some(x) => ... }

everywhere or messes up my interfaces now, when passing stuff around...

I figured this when I found myself using OrElse more often...

-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Me: http://feeds.razie.com/RazvanTech
Playground: http://wiki.homecloud.ca

Re: Option...aly bored

AH-HA...my simpleton OO mind didn't comprehend this before... of course, now
it makes sense and yes, it should help.

Tony Morris-4 wrote:
>
> Option is a collection (a list with a maximum of length 1), however, not
> all things with map/flatMap/filter are a collection. Having been trying
> to educate on this matter for quite some time, I have become quite
> aversive to using analogies such as "collections" to describe "things"
> (type constructors) with map/flatMap/filter.
>

-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Me: http://feeds.razie.com/RazvanTech
Playground: http://wiki.homecloud.ca

Re: Option...aly bored



2009/12/22 Razvan Cojocaru <razie [at] razie [dot] com>



Kevin Wright-4 wrote:
>
> Have you tried using them in a more functional style?
> for-comprehensions and map/flatmap/filter instead of getOrElse
>
Yes, I know - it works out but I don't always deal with collections of
stuff... 
 Sure you do!Option is a collection of size either 0 or 1, you could just as easily use a list and ensure you never put more that one item in.
Rex Kerr-2 wrote:
>
> I'm sure it's possible to overuse Option.  For example, I would almost
> always not want division to return an Option[Int], even though 1/0 does
> not
> return an integer.  I would likely want user interface code that is
> supposed
> to interpret the user's entry into a text field as an Option[MyDataType],
> with None if the user entered something uninterpretable.  (Alternatively,
> I
> might use an Either[String,MyDataType] in this case, so downstream code
> could have access to the raw input.)
>

Yes - I generally use it for containers/Home etc.
+1 on input formLike fields - interesting idea.


Paul Phillips-3 wrote:
>
>   implicit def lifeissafe[T](x: Option[T]): T = x.get
>
+1 -except that this would get rid of all Options...

I am mainly complaining about me using it in my containers/interfaces. I'm
fine with the MapLike library collections.



-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Me: http://feeds.razie.com/RazvanTech
Playground: http://wiki.homecloud.ca

--
View this message in context: http://old.nabble.com/Option...aly-bored-tp26893316p26893904.html
Sent from the Scala - User mailing list archive at Nabble.com.




--
Kevin Wright

mail/google talk: kev [dot] lee [dot] wright [at] googlemail [dot] com
wave: kev [dot] lee [dot] wright [at] googlewave [dot] com
skype: kev.lee.wright
twitter: @thecoda

Copyright © 2013 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland