Created
May 11, 2019 20:52
-
-
Save watzon/ab6e1e6aec4bb00a6a9ae2a998af1abd to your computer and use it in GitHub Desktop.
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
# This example will throw an error at compile time | |
# allowing you to catch it sooner and fix it | |
arr = [] of Int32 | |
def sum(arr) | |
arr.reduce(0) { |acc,i| acc + i } | |
end | |
# Works just fine | |
puts sum [1, 2, 3, 4, 5] | |
# Throws a compile error | |
puts sum ["1", 2, 3, 4, 5] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment