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
| trait Activities | |
| case class PersonWalk(km:Float) extends Activities | |
| case class PersonTalk(words:String) extends Activities | |
| class CompanionPerson { | |
| def perform(act:Activities)= { | |
| act match{ | |
| case PersonWalk(km) => println(km) | |
| case PersonTalk(words) => println(words) |
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
| class Person: | |
| def __init__(self,name): | |
| self.name=name | |
| import json #yaml | |
| v='{"name":"deepak"}' | |
| j=json.loads(v) | |
| person=Person(**j) |
NewerOlder