MIN: How to convert atom reference to int
This feels like a silly question, but I couldn't figure out how to do it.
When you read a value from a dictionary, the type is an atom reference. If I know the value for that key is an integer, how can I convert it from an atom reference to an int? The only solution I could make work is to convert it to a string first.
dict d(args[0]);
int myInt = std::stoi(std::to_string(d["myInt"]));
I feel like there's probably a better way and I'm missing something obvious.
Appreciate any tips.
I'm sure there are other ways, but does this work:int i = atom(d["key"]);
maybe this is safer and more c++ like:
int y = static_cast<int>(static_cast<atom>(d["key"]));