Skip to content

Commit

Permalink
update case class9, readme
Browse files Browse the repository at this point in the history
  • Loading branch information
yennan.liu committed Oct 6, 2021
1 parent 16a1782 commit 4e38a95
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
- [Case Class6](./src/main/scala/ScalaBasic/CaseClass6.scala) - Pattern match : case class nested structure 2
- [Case Class7](./src/main/scala/ScalaBasic/CaseClass7.scala) - case class enumeration
- [Case Class8](./src/main/scala/ScalaBasic/CaseClass8.scala) - case class enumeration
- [Case Class9](./src/main/scala/ScalaBasic/CaseClass9.scala) - case class with user defined class
- case class is still class
- decorate class via case
- for `pattern match` purpose
Expand Down
19 changes: 19 additions & 0 deletions src/main/scala/ScalaBasic/CaseClass9.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import scala.collection.mutable.ListBuffer

object CaseClass9 extends App {

/** demo 1 */
// run
// init
val my_data = myClass_9(ListBuffer(1,2,3), "123", new myConsumerRecord("hi!!", 123))
Expand All @@ -15,6 +16,24 @@ object CaseClass9 extends App {
println(my_data.c)

println(1.toString)

println("==============")

/** demo 2 */
// loop
val my_data_set = ListBuffer(
myClass_9(ListBuffer(1,2,3), "123", new myConsumerRecord("hi!!", 123)),
myClass_9(ListBuffer(4,5,6), "456", new myConsumerRecord("hi!!", 123)),
myClass_9(ListBuffer(7,8,9), "789", new myConsumerRecord("hi!!", 123))
)

println("my_data_set = " + my_data_set)

println("==============")

/** demo 3 */
// map

}

class myConsumerRecord(x:String, y:Int)
Expand Down

0 comments on commit 4e38a95

Please sign in to comment.