- Home /
Hashtables and implicit downcasting of Object to int
I have a hashtable that stores some integer information from a complex-type key. In this case, the weighted distance value between two locations. This value cannot be recomputed trivially, hence storing the value in the hashtable.
dVertex here is the complex data type (x, y, and z point as integers).
connections is the hashtable
public function getDistanceTo(p:dVertex):int {
if(connections.Contains(p)) {
return connections[p];
}
else {
return 0;
}
}
Unity warns me that there is an "Implicit downcast from 'Object' to 'int'" on the third line there and I can't for the life of me figure out how to declare it and remove the error.
"(int)return connections[p]" doesn't work, it whines that there isn't a semicolon after the (int) portion.
Ditto "(Integer)return connections[p]"
It also won't let me use the "as" keyword because int is the as keyword only works for reference types, not value types.
Your answer
Follow this Question
Related Questions
Finding if a specific key contains a specific value in a Hashtable? 1 Answer
A node in a childnode? 1 Answer
Help scrolling puzzle is not. 0 Answers
Moving an object 0 Answers