A Scala DSL example

I was just going through some old notes and found this Scala DSL example from 2010:

Kotlin: A for loop that counts up to some maximum integer value

As a brief note to self, I was just converting some Java code to Kotlin, and the correct way to convert this Java for loop that uses i as a counter:

for (int i=0; i<tabLayout.tabCount; i++) { ...

is with this Kotlin for loop:

for (i in 0 until tabLayout.tabCount) { ...

The key there for me is the 0 until part of the syntax.

A Scala nscala-time example (days to Christmas)

I woke up this morning (June 7, 2013) thinking it must be about 200 days to Christmas. Foregoing any simple ways to determine that, I decided it would be a good time to use the nscala-time library, a Scala wrapper around Joda Time.

Sticking with the time theme, I haven’t much free time today, so without further ado, here is some Scala code that determines the number of days between today and Christmas:

The Perl until loop examples and syntax

Perl until loop FAQ: Can you share some examples of the Perl until loop syntax?

The Perl until loop is similar to the Perl while loop, but essentially does the opposite thing. Where the Perl while operator will run this loop forever:

while ('true')
  # do stuff here

the Perl until loop will never run this loop: