Last active
November 3, 2017 19:22
-
-
Save aarongodin/a639e62aac1f3bbd93ed175c03c29071 to your computer and use it in GitHub Desktop.
This file contains 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
require "json" | |
def boop(props : JSON::Type) | |
puts props | |
end | |
boop({ "test" => "test" }) # => {"test" => "test"} | |
# This has a compile error | |
# | |
# instance variable '@props' of Boop must be JSON::Type, not Hash(String, String) | |
class Boop | |
@props : JSON::Type | |
def initialize(props : JSON::Type) | |
@props = props | |
end | |
def props | |
@props | |
end | |
end | |
b = Boop.new({ "test" => "test" }) | |
puts b.props |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment