2 ms·
I don't think there's a whole lot more we can achieve beyond what you see there... I mean, I guess you could dynamically assign global variables based on the ke
by vidarh 9y ago
I don't think there's a whole lot more we can achieve beyond what you see there... I mean, I guess you could dynamically assign global variables based on the keys, and enforce treating them as strings, so you could reduce it to
jr 'puts{$number+": "+$title}'
E.g by changing the "each" in my example with:
def each █
$J.each do |i|
$I = i;
i.keys.each {|k| eval("$#{k} = $I[k].to_s")}
block.call(i)
end
end
Though this is error prone - e.g. if the key collides with any pre-defined Ruby globals like $stdin... Would probably be worth using a prefix etc.. This is the downside to using a general purpose language for stuff like this instead of a specialised tool like jq which can ignore other syntax concerns..