Universal Extension Methods
Extension methods avaialble for all types
- Source
 - __.scala
 
Def
Any to String add with space
Any to String add with space
Concatenates this and given object string tags with one space in between
true +- 1 +- 2 +- 3 +- 'A' +- 10.Percent tp() // Prints true 1 2 3 A 10%
Note. Java supports AnyRef + AnyRef, resulting in their String representation concatenation.
Scala 2 also used to support this, which was a big mistake, because this not really important + operation, due to it global nature,
would interfere with all attempts to use + for anything else.
Scala 3 got rid of this for good.
Scalqa re-introduces this usefull functionality with such a weired name "+-", hoping it will not pose naming conflits
- Source
 - __.scala
 
Range
Range
Returns Range from current to given value
 ("AAA" <> "BBB").tp  // Prints  AAA <> BBB
Note. An Ordering must be implicitly available
- Source
 - __.scala
 
Exclusive end range
Exclusive end range
Returns <> from current to given value exclusive
 ("AAA" <>> "BBB").tp  // Prints  AAA <>> BBB
Note. An Ordering must be implicitly available
- Source
 - __.scala
 
To option
To option
Returns Opt for current value
 val o : Opt[String] = "Foo".?
Result will be empty option if value is 'null', but non empty for void values. Use .?? instead if void or empty check is required.
- Source
 - __.scala
 
To non-empty value option
To non-empty value option
Returns base value as an option.
Unlike general .? method, this method will create empty option for void or empty values
 val p: Stream[Int]=VOID
 p.?.tp    // prints: Opt(scalqa.val.pack.z.Void)
 p.??.tp  // prints: Opt(VOID)
This method can even safely check Stream for emptiness, returning Stream with original values
def s : Stream[Int] = (1 <> 3).stream.dropFirst(3)
s.??.tp  // prints: Opt(VOID)
s.?.tp   // prints: Opt(Stream())
- Source
 - __.scala
 
Is within
Is within
Returns true if this instance is contained by given container.
 val range = 1 <> 10
 (5 in range).tp   // Prints true
 val pack = (1 <> 10).stream.pack
 (5 in pack).tp    // Prints true
Note. This operation is Macro optimized for Tuples from 2 to 12, so the following check will be ultimatly efficent with no Tuple allocation:
 val s = "ABC"
 s in ("XYZ","BBC","CBC")
- Source
 - __.scala
 
Void check
Void check
Returns true if target is void
Note: Operation can fail for null value, use .self.isVoid if null check is required
- Source
 - __.scala
 
Not void check
Not void check
Returns true if target is non void
Note: Operation can fail for null value, use .self.nonVoid if null check is required
- Source
 - __.scala
 
Self view
Self view
Returns additional "self" library available to this instance
The most popular feature is doing some processing within context of an anonimous function
val a: Array[Int] = new Array[Int](3).self(_.fill(5))
// Compare to
val b: Array[Int] = { val a = new Array[Int](3); a.fill(5); a }
Note. Due to opaque implementation and inlining, there is no performance difference in the above two cases
- Source
 - __.scala
 
Make String
Make String
Returns String representation of base value.
.tag has to universally be used instead of Java .toString. This is due to opaque types,
which by definition cannot override .toString, but have facility to provide correct .tag.
In traditional objects, .tag by default calls .toString.
val v: Time.Length =  100.Seconds
v.tag.tp       // Prints 1 min 40 secs
// Compare to
v.toString.tp  // Prints 100000000000
- Source
 - __.scala
 
Tag print
Tag print
tp should be pronounced as "tip"
tp is a functional equivalent to println for debugging, education and demonstration purposes
tp should never be inside a production program, println should be used instead. Searching code for tp should immediately locate debugging fragments.
// Compare:
1.tp
// vs.
println(1.tag)
(1 <> 10).stream.tp
// vs.
println((1 <> 10).stream.tag)
100.Seconds.tp
// vs.
println(100.Seconds.tag)
Also, there is postfix like overload of tp on String type
"Results:" +- 1 +- 2 +- 3 +- 4.Percent tp()
// vs.
println("Results:" +- 1 +- 2 +- 3 +- 4.Percent)
- Source
 - __.scala