Last active
January 17, 2017 14:15
-
-
Save bcardiff/58d2c8cec73b0971b6eb990d6311485c 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
require "json" | |
struct Slice(T) | |
def to_json(json : JSON::Builder) | |
json.array do | |
each do |e| | |
e.to_json(json) | |
end | |
end | |
end | |
end | |
empty = Slice(UInt8).empty | |
foo = Slice[1, 2, 3] | |
puts empty.to_json # => [] | |
puts foo.to_json # => [1,2,3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment