Top "Implicit-conversion" questions

Converting an object, variable or value from one type to another to satisfy a type restriction, without specifically requesting that conversion through language syntax.

Can I add an implicit conversion for two classes which I don't directly control?

I'd like to be able to implicitly convert between two classes which are otherwise incompatible. One of the classes is …

c# f# operator-overloading extension-methods implicit-conversion
Implicit conversion to Runnable?

As an exercise, I tried to create an implicit conversion that would accept a function and produce a Runnable. That …

scala runnable implicit-conversion
Option getOrElse type mismatch error

Why does this code raise a type mismatch error in Scala 2.9.2? I expected that getOrElse returns type String but actually …

scala implicit-conversion type-mismatch
Should implicit classes always extend AnyVal?

Say I'm writing an extension method implicit class EnhancedFoo(foo: Foo) { def bar() { /* ... */ } } Should you always include extends AnyVal in …

scala implicit-conversion
When can I use explicit operator bool without a cast?

My class has an explicit conversion to bool: struct T { explicit operator bool() const { return true; } }; and I have an …

c++ implicit-conversion
assigning lambda to std::function

Why is the 2nd assignment allowed, when the inferred return type is std::nullptr_t? With function pointers this is …

c++ lambda c++11 implicit-conversion std-function
spray-json error: could not find implicit value for parameter um

I have this case class case class Person(val name: String) object JsonImplicits extends DefaultJsonProtocol { implicit val impPerson = jsonFormat1(Person) } …

scala akka implicit-conversion spray
Casting String to Int using scala extractors

I am trying to cast a String to Int using extractors. My code looks as follows. object Apply { def unapply(…

scala type-conversion implicit-conversion unapply
More on implicit conversion operators and interfaces in C# (again)

Okay. I've read this post, and I'm confused on how it applies to my example (below). class Foo { public static …

c# interface implicit-conversion
How can I chain implicits in Scala?

The pimp-my-library pattern allows me to seemingly add a method to a class by making available an implicit conversion from …

scala implicit-conversion implicits