Suppress display of a result in scala worksheet
Asked Answered
T

1

6

I would like to suppress the output of helper variables in Scala worksheet:

  val sqs = scen.rssis.toSeq.filter { case (ap,s) =>
    s.exists(e => e.epoch > 1) }.sortBy { -_._2.length }.take(10)
                                                  //> sqs  : 
                                                  // *snip* a lot of stuff I'd rather not have
                                                  //| Output exceeds cutoff limit.
  sqs foreach { case (api,s) =>
    println(f"${scen.aps(api).ssid}%-10s ${s.length}% 5d")
  }                                               //> 2WIRE230      74
                                                  //| 2WIRE736      74
                                                  //| Jamie56       73
                                                  //| VVHOA         69
                                                  //| 2WIRE059      68
                                                  //| Rainsnet      68
                                                  //| 2WIRE519      67
                                                  //| 2WIRE604      65
                                                  //| neo_vex_24    63
                                                  //| ALEMANIA7     63

Is there a way to suppress the output of the assignment in Scala worksheet?

Tertial answered 8/5, 2013 at 17:46 Comment(0)
Z
6

There is no explicit way to suppress the output. However, you can easily achieve this by moving the helper declarations in an outer (or nested) object.

For instance, the following would do it:

object worksheet {
  object helper {
    val sqs = scen.rssis.toSeq.filter { case (ap,s) =>
      s.exists(e => e.epoch > 1) }.sortBy { -_._2.length }.take(10)
  }

  helper.sqs foreach { case (api,s) =>
    println(f"${scen.aps(api).ssid}%-10s ${s.length}% 5d")
  } 
}
Zoogloea answered 8/5, 2013 at 18:10 Comment(1)
Ohhhhh.... Next steps: 1. Add import helper._. 2. Write macro to do it for us...Tertial

© 2022 - 2024 — McMap. All rights reserved.