Skip to content

Instantly share code, notes, and snippets.

@dbehnke
Created January 7, 2014 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbehnke/8308143 to your computer and use it in GitHub Desktop.
Save dbehnke/8308143 to your computer and use it in GitHub Desktop.
import org.joda.time._
val typedef = Seq("string", "datetime")
val data = Seq("hi","014-01-07T15:57:52.253-05:00")
val x: Seq[Any] = (for(i <- 0 to data.length - 1)
yield({
if (i <= typedef.length)
typedef(i) match {
case "datetime" => new DateTime(data(i))
case _ => data(i).asInstanceOf[String]
}
else data(i)
}))
@dbehnke
Copy link
Author

dbehnke commented Jan 7, 2014

Given Two sequences:

  • Sequence 1 (typedef) defines the type.
  • Sequence 2. contains the data

Combines based on definition (typedef) the data into a sequence of Any type.

In the example result x: Seq[Any] = Vector(hi, 0014-01-07T15:25:41.253-05:32:11)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment