Skip to content

Instantly share code, notes, and snippets.

@laginha87
Created May 2, 2018 18:17
Show Gist options
  • Save laginha87/30c638e4fa7a544f9df8e7551fc405a1 to your computer and use it in GitHub Desktop.
Save laginha87/30c638e4fa7a544f9df8e7551fc405a1 to your computer and use it in GitHub Desktop.
crystal nil branching
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