# Scala question - how to tell if session(VAR) is a Seq\[String\] or just a String?

**URL:** <https://community.gatling.io/t/scala-question-how-to-tell-if-session-var-is-a-seq-string-or-just-a-string/2611>\
**Category:** Gatling (Open-Source)\
**Created:** [October 14, 2015, 6:59pm UTC](https://community.gatling.io/t/scala-question-how-to-tell-if-session-var-is-a-seq-string-or-just-a-string/2611 "2015-10-14T18:59:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jarrowwx](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jarrowwx](https://community.gatling.io/u/jarrowwx)\
**Post date:** [October 14, 2015, 6:59pm UTC](https://community.gatling.io/t/scala-question-how-to-tell-if-session-var-is-a-seq-string-or-just-a-string/2611/1 "2015-10-14T18:59:29Z")

</div>

I’m trying to write a generic debug print of a session variable value. I typically use strings and sequences of strings, only. When it is a string, I will just dump the value. When it is a sequence, I want to make it look like a bullet list on the console.

Here’s my code (so far):

`def ValueOf( s : SessionVariable ) : ( Session => Validation[Session] ) = session => { println( "\n===========================================================================" ) println( "DEBUG - Value of Session Variable:" + s ) println( "---------------------------------------------------------------------------" ) val v = session( s ).as[Any] println( v match { case s : String => s case seq : Seq[String] => " - " + seq.mkString( ",\n - " ) case x => x.toString }) println( "===========================================================================" ) session }`

And the compile warning I get is:

`... non-variable type argument String in type pattern Seq[String] (the underlying of Seq[String]) is unchecked since it is eliminated by erasure [warn] case seq : Seq[String] => " - " + seq.mkString( ",\n - " ) [warn] ^ [warn] one warning found`

Can anyone tell me what is the RIGHT way of doing what I am trying to accomplish?

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [October 14, 2015, 8:10pm UTC](https://community.gatling.io/t/scala-question-how-to-tell-if-session-var-is-a-seq-string-or-just-a-string/2611/2 "2015-10-14T20:10:29Z")

</div>

Java (and Scala as a consequence) loses type parameters at runtime. That’s called type erasure.  
Once again, something stupid in Java because of the Java 4 compatibility “greater good”… Java 5 was released more than 10 years ago…

As pattern matching is something that happens at runtime, Scala has no way of telling appart Seq[String], Seq[Int], Seq[Whatever], so the compiler warns you that your pattern matching might produce unexpected results.

As you actually don’t need Strings, you can simply write:

case seq: Seq[\_] =\> seq.mkString(" - ", ",\n - ", “”)

---

<div class="post-metadata">

**Author:** ![jarrowwx](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jarrowwx](https://community.gatling.io/u/jarrowwx)\
**Post date:** [October 15, 2015, 11:54am UTC](https://community.gatling.io/t/scala-question-how-to-tell-if-session-var-is-a-seq-string-or-just-a-string/2611/3 "2015-10-15T11:54:13Z")

</div>

On a whim, I tried using Seq[Any] and that also did the trick. I like the underscore trick, though. Thanks for the help. It is much appreciated.
