-2

I am new to Scala. I have a case class. The code is given below.

case class ReportInfoPosted(
  name:  Option[String],
  id:    Option[String],
  order: Option[Int]
)

I also have a function which returns an seq of objects of the class. This is what is being returned.

ReportInfoPosted(Some(Sales Dollars),Some(4e6d8ec1-4c00-4193-be15-2fa0509849a7),Some(0))

Now I want to read values from the object. I have looked at some resources on the web, this is what I have tried.

for(el <- reportlist){
    println(el.input)
}

for(el <- reportlist){
    println(el.id)
}

BTW, reportlist is the seq of obejcts. None are working. I don't know what to do.

halfer
  • 19,824
  • 17
  • 99
  • 186
odbhut.shei.chhele
  • 5,834
  • 16
  • 69
  • 109

1 Answers1

3

Your question is pretty vague. Do you just mean this?

val a = ReportInfoPosted(Some("a"), Some("a"), Some(1))
val b = ReportInfoPosted(Some("b"), Some("b"), Some(2))
val reportlist: Seq[ReportInfoPosted] = Seq(a,b)

for (report <- reportlist) {
  println(report.name)
}

prints:

Some(a)
Some(b)
dhg
  • 52,383
  • 8
  • 123
  • 144