What does the arrow (“->”) operator do in Kotlin?

The -> is part of Kotlin’s syntax (similar to Java’s lambda expressions syntax) and can be used in 3 contexts: when expressions where it separates “matching/condition” part from “result/execution” block val greet = when(args[0]) { “Apple”, “Orange” -> “fruit” is Number -> “How many?” else -> “hi!” } lambda expressions where it separates parameters from … Read more

What does ‘&’ do in a C++ declaration?

The “&” denotes a reference instead of a pointer to an object (In your case a constant reference). The advantage of having a function such as foo(string const& myname) over foo(string const* myname) is that in the former case you are guaranteed that myname is non-null, since C++ does not allow NULL references. Since you … Read more

Why does >= return false when == returns true for null values?

There was a huge debate about this oddity when the feature was originally designed back in C# 2.0. The problem is that C# users are completely used to this being meaningful: if(someReference == null) When extending equality to nullable value types, you have the following choices. Nullable equality is truly lifted. If one or both … Read more

Conversion constructor vs. conversion operator: precedence

You do copy initialization, and the candidate functions that are considered to do the conversions in the conversion sequence are conversion functions and converting constructors. These are in your case B(const A&) operator B() Now, that are the way you declare them. Overload resolution abstracts away from that, and transforms each candidate into a list … Read more

Akka in Scala, exclamation mark and question mark

Shamelessly copied [awesome] official doc (look Send messages section for more): Messages are sent to an Actor through one of the following methods. ! means “fire-and-forget”, e.g. send a message asynchronously and return immediately. Also known as tell. ? sends a message asynchronously and returns a Future representing a possible reply. Also known as ask.