Top "Syntactic-sugar" questions

Syntactic sugar is a computer science term that refers to syntax within a programming language that is designed to make things easier to read or to express.

How does the Java 'for each' loop work?

Consider: List<String> someList = new ArrayList<String>(); // add "monkey", "donkey", "skeleton key" to someList for (String …

java foreach syntactic-sugar
What is the purpose of "!" and "?" at the end of method names?

Sometimes I see methods in Ruby that have "?" and "!" at the end of them, e.g: name = "sample_string" name.…

ruby methods syntax predicate syntactic-sugar
Is there a literal notation for an array of symbols?

I like this literal expression for an array of strings: %w( i can easily create arrays of words ) I am …

ruby arrays symbols syntactic-sugar
C# property and ref parameter, why no sugar?

I just ran across this error message while working in C# A property or indexer may not be passed as …

c# properties syntactic-sugar reference-parameters
How does Scala's apply() method magic work?

In Scala, if I define a method called apply in a class or a top-level object, that method will be …

scala syntactic-sugar magic-methods companion-object
Shorthand for for-loop - syntactic sugar in C++(11)

Actually these are two related questions. I know there is a new syntax in C++11 for range-based for loops of …

c++ c++11 for-loop syntax syntactic-sugar
Magic First and Last Indicator in a Loop in Ruby/Rails?

Ruby/Rails does lots of cool stuff when it comes to sugar for basic things, and I think there's a …

ruby-on-rails ruby syntactic-sugar
Python decorator best practice, using a class vs a function

As I've understood it there are two ways to do a Python decorator, to either use the __call__ of a …

python python-2.7 decorator syntactic-sugar
WITH statement in Java

In VB.NET there is the WITH command that lets you omit an object name and only access the methods …

java vb.net syntax syntactic-sugar
Destructuring assignment - object properties to variables in C#

JavaScript has a nifty feature where you can assign several variables from properties in an object using one concise line. …

c# syntactic-sugar