Created
May 2, 2018 18:17
-
-
Save laginha87/30c638e4fa7a544f9df8e7551fc405a1 to your computer and use it in GitHub Desktop.
crystal nil branching
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
a = [1,2,3, nil] | |
b = a.first | |
if b # Create a branch of nil/not_nil | |
puts b + 1 | |
else | |
puts "B is nil" | |
end | |
puts b.not_nil! + 1 # Use not_nil! inline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment