Typescript: Index signature is missing in type

The problem is that when the type is inferred, then the type of o is: That’s not the same as { dic: { [name: string]: number } }. Critically, with the top signature you’re not allowed to do something like o.dic[‘x’] = 1. With the 2nd signature you are. They are equivalent types at runtime (indeed, they’re the exact … Read more

dynamic_cast and static_cast in C++

Here’s a rundown on static_cast<> and dynamic_cast<> specifically as they pertain to pointers. This is just a 101-level rundown, it does not cover all the intricacies. static_cast< Type* >(ptr) This takes the pointer in ptr and tries to safely cast it to a pointer of type Type*. This cast is done at compile time. It will only perform the cast if the types … Read more

Explanation of ClassCastException in Java

Straight from the API Specifications for the ClassCastException: Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. So, for example, when one tries to cast an Integer to a String, String is not an subclass of Integer, so a ClassCastException will be thrown.