Interfaces vs Types in TypeScript

Original Answer (2016) As per the (now archived) TypeScript Language Specification: Unlike an interface declaration, which always introduces a named object type, a type alias declaration can introduce a name for any kind of type, including primitive, union, and intersection types. The specification goes on to mention: Interface types have many similarities to type aliases for object type literals, … Read more

Understanding regex in Java: split(“\t”) vs split(“\\t”) – when do they both work, and when should they be used

When using “\t”, the escape sequence \t is replaced by Java with the character U+0009. When using “\\t”, the escape sequence \\ in \\t is replaced by Java with \, resulting in \t that is then interpreted by the regular expression parser as the character U+0009. So both notations will be interpreted correctly. It’s just the question when it is replaced with the corresponding character.

Is C++ an Object Oriented language?

C++ is usually considered a “multi-paradigm” language. That is, you can use it for object-oriented, procedural, and even functional programming. Those who would deny that C++ is OO generally have beef with the fact that the primitive types are not objects themselves. By this standard, Java would also not be considered OO. It is certainly … Read more

Does “\d” in regex mean a digit?

I found that in 123, \d matches 1 and 3 but not 2. I was wondering if \d matches a digit satisfying what kind of requirement? I am talking about Python style regex. Regular expression plugin in Gedit is using Python style regex. I created a text file with its content being Only 1 and 3 are matched by the regex \d; 2 is not. Generally for a sequence of digit numbers … Read more

Python function execution

If it is a function, it needs to return something. Otherwise, running it is kind of useless. So you probably need to say: You probably want to read more about functions in Python and when this would make sense (passing by reference, for example). This can be a good starting point: Python functions.