1. In scala you could write
class MyClass[A[_]](a: A)
in C#/F# this is invalid:
class MyClass<A<?>> { public MyClass(A a) { } }
2. Implicit Conversion: In C#/F# you get extension methods, but it doesn't help you take an existing class and ad-hoc make it implement an interface.
So in scala I could do this:
trait XMLSerializable { def toXML(): XMLNode }
implicit def toXMLSerializable(li: List[_]): XMLSerializable = new XMLSerializable { def toXML = { transformListToXML(li) } }
val genericXmlSerializable: XMLSerializable = List[Int](1,2,3,4)
1. In scala you could write
and it can only take a 'container' (List/Future/Option).in C#/F# this is invalid:
You could make a plain ol' generic that took a concrete type List<Int> but not just on the type.2. Implicit Conversion: In C#/F# you get extension methods, but it doesn't help you take an existing class and ad-hoc make it implement an interface.
So in scala I could do this:
and then let's say I want to make existing classes in the standard library implement this interface: I can now do: