Skip to content

Instantly share code, notes, and snippets.

@bcardiff
Last active January 17, 2017 14:15
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 bcardiff/58d2c8cec73b0971b6eb990d6311485c to your computer and use it in GitHub Desktop.
Save bcardiff/58d2c8cec73b0971b6eb990d6311485c to your computer and use it in GitHub Desktop.
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