Last active
March 6, 2018 17:33
-
-
Save mgwidmann/43ea07f69d05ccfddd0e8579be748393 to your computer and use it in GitHub Desktop.
Revisions
-
mgwidmann revised this gist
Mar 6, 2018 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -16,3 +16,5 @@ def safeOption(shouldBeSafe : Option[String]) : String = { } safeOption(null) // BOOM java.lang.NullPointerException :( // Somes can hold Nones inside them :(, have to use flatMap to remove Map("a" -> "b").get("a").map(x => Try(x.toInt).toOption) == Some(None) -
mgwidmann revised this gist
Mar 5, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,12 +7,12 @@ Set(1,2,3).sameElements(Set(3,2,1)) // false Some(null).get // No exception :(, Some(null) should result in a None IMO // Option objects might be null!!! def safeOption(shouldBeSafe : Option[String]) : String = { if (shouldBeSafe.isDefined) { return "Yep its safe" } else { return "No, it was not" } } safeOption(null) // BOOM java.lang.NullPointerException :( -
mgwidmann revised this gist
Mar 5, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,5 +14,5 @@ def safeOption(shouldBeSafe : Option[String]) = { return "No, it was not" } } safeOption(null) // BOOM -
mgwidmann revised this gist
Mar 5, 2018 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,3 +5,14 @@ pow(2, 31).intValue + 1 > 0 // false Set(1,2,3).sameElements(Set(3,2,1)) // false Some(null).get // No exception :(, Some(null) should result in a None IMO // Option objects might be null!!! def safeOption(shouldBeSafe : Option[String]) = { if (shouldBeSafe.isDefined) { return "Yep its safe" } else { return "No, it was not" } } safeOption(null) // BOOM -
mgwidmann revised this gist
Mar 5, 2018 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,3 +3,5 @@ pow(2, 31).intValue + 1 > 0 // false Set(1,2,3).sameElements(Set(3,2,1)) // false Some(null).get // No exception :(, Some(null) should result in a None IMO -
mgwidmann revised this gist
Feb 13, 2018 . No changes.There are no files selected for viewing
-
mgwidmann revised this gist
Feb 13, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,3 +2,4 @@ pow(2, 31).intValue + 1 > 0 // false Set(1,2,3).sameElements(Set(3,2,1)) // false -
mgwidmann created this gist
Jan 25, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ {} + "" == "()" // true pow(2, 31).intValue + 1 > 0 // false