Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Scala
Posted by: Pahay Ragh
Added: Oct 26, 2020 1:36 AM
Views: 12
Tags: scala
  1.     //    Type classes (implicit objects)
  2.     def foo2[B, A<:B] (a:A,b:B) = print("OK")
  3.     class A;
  4.     class B;
  5.  
  6.  
  7.     implicit def a2b(a:A) = new B
  8.     foo2(new A, new B)  // implicit conversion!