Skip to content

Instantly share code, notes, and snippets.

@DougEverly
Created November 10, 2016 15:35
Show Gist options
  • Select an option

  • Save DougEverly/4a9a4fa1e08fc3086dbb812b21c5d858 to your computer and use it in GitHub Desktop.

Select an option

Save DougEverly/4a9a4fa1e08fc3086dbb812b21c5d858 to your computer and use it in GitHub Desktop.
struct Int32
def to(t : Int32.class)
self
end
def to(t : Int64.class)
self.to_i64
end
def to(t : String.class)
self.to_s
end
def foo(t : (JSON.class | MessagePack.class))
dog.to(t, io)
end
end
a = 13_i32
a.to(Int64)
a.to(String)
a.to(Int32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment