The <% consciousness in 1.scala is a "view Bounds" (Horizon), which is more widely used and can be implicitly converted, and is a syntactic sugar than <
The following two formulations are equivalent, exactly the same after compilation.
Object Test { def main (args:array[string]) { } def method1[a<% Int] (a:int): Unit ={ } def method2[ A] (a:int) (implicit b:a=>int): Unit ={ }}
View Code
The definition of Function1 is as follows
2. view bounds Same as context bounds (context defined) is also an implicit parameter of the syntax sugar
Object Test { def main (args:array[string]) { } def Method1[a:list] (a:a): Unit ={ } def method2 A (A:A) (implicit b:list[a]): Unit ={ }}
Reference:
1.http://www.scala-lang.org/api/2.10.4/#scala. Function1
2.http://hongjiang.info/scala-type-system-view-bounds/
3.http://hongjiang.info/scala-type-system-context-bounds/
View bound and context bound in Scala