Skip to content

Instantly share code, notes, and snippets.

@aarongodin
Last active November 3, 2017 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarongodin/a639e62aac1f3bbd93ed175c03c29071 to your computer and use it in GitHub Desktop.
Save aarongodin/a639e62aac1f3bbd93ed175c03c29071 to your computer and use it in GitHub Desktop.
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