The Crystal programming language | http://crystal-lang.org | Fund Crystal's development: http://is.gd/X7PRtI | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/
a, b : Int32
struct
s, but not class
es
#converts tuples to json
def to_json(keys : Tuple, values : Tuple) : String
if keys.size != values.size
puts "Different tuple sizes!"
return ""
end
json = "{"
keys.size.times do |i|
key = "\"" + keys[i] + "\":"
val = "\"" + values[i] + "\","
json += (key + val)
end
json.rchop + "}"
end