Top "Syntax" questions

Syntax refers to the actual language elements and symbols themselves.

Java generics - why is "extends T" allowed but not "implements T"?

I wonder if there is a special reason in Java for using always "extends" rather than "implements" for defining bounds …

java generics syntax design-choices
What is the difference between . (dot) and $ (dollar sign)?

What is the difference between the dot (.) and the dollar sign ($)? As I understand it, they are both syntactic sugar …

haskell syntax function-composition
Null check in an enhanced for loop

What is the best way to guard against null in a for loop in Java? This seems ugly : if (someList != …

java syntax loops for-loop
Why is list initialization (using curly braces) better than the alternatives?

MyClass a1 {a}; // clearer and less error-prone than the other three MyClass a2 = {a}; MyClass a3 = a; MyClass a4(a); …

c++ c++11 syntax initialization list-initialization
How to use a dot "." to access members of dictionary?

How do I make Python dictionary members accessible via a dot "."? For example, instead of writing mydict['val'], I'd like …

python dictionary syntax nested
Is there a foreach in MATLAB? If so, how does it behave if the underlying data changes?

Is there a foreach structure in MATLAB? If so, what happens if the underlying data changes (i.e. if objects …

matlab syntax
Python: SyntaxError: keyword can't be an expression

In a Python script I call a function from rpy2, but I get this error: #using an R module res = …

python syntax syntax-error keyword
Best way to "negate" an instanceof

I was thinking if there exists a better/nicer way to negate an instanceof in Java. Actually, I'm doing something …

java syntax
How to normalize a 2-dimensional numpy array in python less verbose?

Given a 3 times 3 numpy array a = numpy.arange(0,27,3).reshape(3,3) # array([[ 0, 3, 6], # [ 9, 12, 15], # [18, 21, 24]]) To normalize the rows of the 2-dimensional array I thought …

python arrays syntax numpy normalization
Best way to split string into lines

How do you split multi-line string into lines? I know this way var result = input.Split("\n\r".ToCharArray(), StringSplitOptions.…

c# string syntax multiline