Last active
          August 29, 2015 14:25 
        
      - 
      
- 
        Save joecwu/f0d21f27c212866f4024 to your computer and use it in GitHub Desktop. 
    Blog Scala API Document Implicit Parameter sample code. http://blog.joecwu.com/2015/07/scava-scala-scala-api-document-implicit.html
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | case class TracerId(tid:String) | |
| object TestApp { | |
| implicit val tracerId = TracerId(java.util.UUID.randomUUID().toString) // tracerId can be defined and retrieved from HTTP request header. | |
| def run(){ | |
| methodA(1) | |
| methodB | |
| } | |
| def methodA(i:Int)(implicit tracerId:TracerId) = { | |
| println(s"A: I have tracerId:[$tracerId].") | |
| } | |
| def methodB(implicit tracerId:TracerId) = { | |
| println(s"B: I have tracerId:[$tracerId].") | |
| methodC("YOYO") | |
| } | |
| def methodC(str:String)(implicit tracerId:TracerId) = { | |
| println(s"C: I have tracerId:[$tracerId] as well.") | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment