F# in Action: A Revised Edition of Get Programming with F# by Isaac Abraham
Author:Isaac Abraham [Abraham, Isaac]
Language: eng
Format: epub, mobi
Publisher: Manning Publications Co.
Published: 2024-04-15T22:00:00+00:00
Figure 9.1 Unlike an int, an int option can have two outcomes: either it wraps a real int, or it has nothing in it. You need to pattern match on the value to safely check whether thereâs data inside it and then proceed accordingly.
Another crucial thing to note is as everything in F# is an expression, you have to handle both the Some and None cases. In other words, you canât just deal with the âhappy path.â While this might sound like extra work, think about it: if youâve modeled your domain to say that a given value might be absent, why wouldnât you want to handle that?
Getting the value out of an option
There is a .Value member of the option type that allows you to get the underlying data without needing to pattern match first. If the value doesnât exist, youâll get a runtime exception. Donât ever use this in a real application, no matter how sure you are that the value will never be None. Youâre essentially turning off the type system and losing all the safety of option. It is, however, sometimes useful as an escape hatch if youâre working in scripts in a data exploration mode and want to quickly get at some data you know is there.
Download
F# in Action: A Revised Edition of Get Programming with F# by Isaac Abraham.mobi
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
ActiveX | ASP.NET |
Cold Fusion | CSS |
DHTML | Java Server Pages |
JavaScript | PHP |
Python | Ruby |
XSL |
Hello! Python by Anthony Briggs(9423)
The Mikado Method by Ola Ellnestam Daniel Brolund(9352)
Dependency Injection in .NET by Mark Seemann(8896)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7440)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7161)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6275)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6006)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5535)
Kotlin in Action by Dmitry Jemerov(4683)
Audition by Ryu Murakami(4140)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(3991)
Functional Programming in JavaScript by Mantyla Dan(3742)
Svelte with Test-Driven Development by Daniel Irvine(3382)
Layered Design for Ruby on Rails Applications by Dementyev Vladimir;(3010)
Test-Driven Development with PHP 8 by Rainier Sarabia(2980)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(2865)
WordPress Plugin Development Cookbook by Yannick Lefebvre(2688)
Architecting Modern Java EE Applications: Designing lightweight, business-oriented enterprise applications in the age of cloud, containers, and Java EE 8 by Daschner Sebastian(2570)
Web Development with Django by Ben Shaw Saurabh Badhwar(2438)