Attached Constructors

Java and Scala widely use a conversion pattern which starts with a prefix "to":

    val i : Int    = 12
    val s : String = i.toString
    val d : Double = i.toDouble
    val d : Byte   = i.toByte

Scalqa basically drops the prefix "to" in cases when the base type is a straight forward argument for creating target type. This makes a method name start with an upper case, but this is exactly what differentiates constructor methods from regular methods:

    val i : Int    = 12
    val d : Double = i.Double
    val d : Byte   = i.Byte

This pattern really shines with simple opaque types, when constructors are attached to primitives:

    val p   : Percent     = 12.Percent
    val tl1 : Time.Length = 14.Minutes
    val tl2 : Time.Length = 3.Seconds
    val bd  : BigDecimal  = 3.14.Big

Linked are the definitions for attached default constructor methods on Int and Double.