score:1
Accepted answer
First, it's a good idea to create a case class to represent period of time
case class Period(start: Date, end: Date)
So, declare constants like that :
val period1 = Period(d1, d2)
val period2 = Period(d3, d4)
And create a sequence and iterate over with a for comprehension
for (d <- Seq(period1, period2)) yield {…}
Source: stackoverflow.com
Related Query
- Refactor Ruby loop into Scala loop
- Introduce a counter into a loop within scala
- for loop into map method with Spark using Scala
- scala loop to add date string into a seq
- How to loop over array and concat elements into one print statement or variable Spark Scala
- How do I can convert Scala for loop into Java
- Insert value into Mutable List using for loop (index wise) in scala
- Scala best way of turning a Collection into a Map-by-key?
- Converting a Java collection into a Scala collection
- Drop into interpreter during arbitrary scala code location
- How to pass Scala array into Scala vararg method?
- Load Scala file into interpreter to use functions?
- How to insert double quotes into String with interpolation in scala
- How to split strings into characters in Scala
- How to convert Row of a Scala DataFrame into case class most efficiently?
- How are Scala traits compiled into Java bytecode?
- Split 1 column into 3 columns in spark scala
- Most elegant repeat loop in Scala
- Scala - convert List of Lists into a single List: List[List[A]] to List[A]
- Scala for loop over two lists simultaneously
- Does Scala have a library method to build Option-s that takes into account empty strings?
- How to load 100 million records into MongoDB with Scala for performance testing?
- Ruby vs Scala - pros and contras of each one
- How do you turn a Scala list into pairs?
- Reading TSV into Spark Dataframe with Scala API
- How to integrate Scala into core Android platform?
- How to convert Scala Map into JSON String?
- Read All Lines of BufferedReader in Scala into a String
- Convert Scala Set into Java (java.util.Set)?
- Can I stop the execution of an infinite loop in Scala REPL?
More Query from same tag
- How do I create an MQTT sink for Spark Streaming?
- Copied data to clipboard get lost whenever I close the frame
- try not a full blown expression?
- Scale Matrix in Scala/Spark
- Array initializing in Scala
- Change priority of items in a priority queue
- Apache Commons CompressorInputStream and HDFS Gzip files error No Compressor found for the stream signature
- Scala - null (?) as default value for named Int parameter
- Scala syntax which I don't understand
- How to find out who and from where called a method?
- Can I pass parameters to Scala REPL using :load?
- sentence parsing is running extremely slowly
- How to execute a job manually with injected dependencies
- Scala: create array from iterator over array
- Scala strange error when using foldRight with operator syntax
- Why can't this simple scala example be compiled?
- Can You Explain this with an example.Encountered this when studying HOF in scala
- Why are value classes restricted to AnyVal?
- get Json Values in Scala scala.util.parsing.json.JSON
- How can I get a Random URL on http request for Gatling?
- How to make Page Visibility API working in Scala.js?
- Merge a sequence of tuples into another sequence in scala
- Not between in scala spark
- How do I configure scoverage when using SBT?
- Sbt plugin published to nexus with sbt.version 1.2.8 is not resolved by sbt projects which are using sbt.version >1.2.8
- How to tell an object is companion object of a Traversable(List, Seq..) in macro
- How to convert scala code block to string?
- How to handle comma in a cell in csv file in Spark/Scala
- Akka Typed and having base class for MessageAdapters
- Running Scala code in Eclipse with Maven enabled