This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Extracting Values from Optional in Scala | |
| //a. This works well if you have a defined value for your else | |
| val value = Some("Data") | |
| value.getOrElse("No Value") | |
| //b Using match you can extract the value and do anything you want with it | |
| value match { | |
| case Some(i) => println(s"There is a value $i") | |
| case _ => println("There is nothing in value") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math._ | |
| object DistanceMetrics { | |
| /** | |
| * distance method helps get the Euclidean Distance between two vectors | |
| * Euclidean Distance tests the space betweeen two Vectors and the result is | |
| * between 0 and 2 where: | |
| * 0 means the space between them is 0 | |
| * 2 meanns the space between the two vector is at maximum | |
| * @param xs |
NewerOlder