An Option can be thought of as collections of zero or one elements. I leave it here for an example of how not to do it. An Option is a data structure that contains either a single value, or no value at all. I wrote it when I was not familiar with Scala. This use is closely related to static members in Java.(EDIT: this is not the best or most idiomatic way to do it. One place we get an Option value is through the get () method for a Map. This means that it is either a Some T or a none object. Most often, you need an object to hold methods and values/variables that shall be available without having to first instantiate an instance of some class. A Scala Option holds zero or one element of a type. if there is a class C, then object C is the companion object of class C note that the companion object is not automatically an instance of C.Īlso see Scala documentation for object and class.object O extends T makes the object O an instance of trait T you can then pass O anywhere, a T is expected.Ive organized his statements here in the following three sections. SCALA OPTION SERIES
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |