Created
November 10, 2016 15:35
-
-
Save DougEverly/4a9a4fa1e08fc3086dbb812b21c5d858 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
| 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