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/
formdata.field("type", "dtg")
as the first field?
@elorest: I don't know if this qualifies as "better"....
class Array
def t
T
end
end
arr = Array(Hash(String, String | UInt64 | Int64 | Float64)).new
arr << arr.t.new
It's shorter, but calling the method that was added to Array #t is not particularly clear, and it is dependent on implementation details, but it does take advantage of the type of the array already being known. It could maybe be made less objectionable with:
class Array
def add_new_value(*args)
self << T.new(*args)
end
end
arr = Array(Hash(String, String | UInt64 | Int64 | Float64)).new
arr.add_new_value
Or something kind of similar to that.
I don't know of any standard method that gives you the type that an array stores, unless you go and create one yourself as above.
You could finagle something with a macro and typeof, which might also be reasonable if you are repeating the above pattern A LOT, but it also won't be particularly pretty in implementation).
done = Channel(Nil).new
spawn do
call_next(context)
ensure
done.send nil
end
select
when done.receive
# print content
when timeout(34.seconds)
# how to print stack trace to investigate which code causes long processing
raise "Server could not process_request in 34 seconds"
end
call_next(context)
is more or less like your Athena's Controller
Fiber.current.running_time