c

Any.Itself

final class _Class[A] extends AnyVal

Any.Itself is a library available for every single object in Scalqa

Any.Itself has to be accessed of <any>.I notation

Because, of <any>.I access Any.Itself has luxury of providing diverse functionality on every object with no naming conflicts with application methods

val txt = "abc".I(_ lp)     // Prints: "abc"

txt.I.id lp                 // Prints: scalqa.String@1

txt.I.hashIndex lp          // Prints: 1
Ordering
  1. Alphabetic
Inherited
  1. Itself
  2. scala.AnyVal
  3. scala.Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Constant

  1. val real: A
    Attributes
    protected
    Definition Classes
    _Class

Method

  1. def apply(f: (A) ⇒ Any): A

    Process

    Process

    Runs specified function for this

    Returns this

    // Defining array and data in one line
    val array = new Array[Int](3).I(a => {a(1)=1; a(2)=2})

    *

    Definition Classes
    _Class
  2. def as[B](f: (A) ⇒ B)(implicit t: ClassTag[B]): B

    Adapt

    Adapt

    Adapts this to the target type

    If this implements target type, simple asInstanceOf is returned

    Otherwise conversion function is used and the result is returned

    val x:  Idx[Int]   = Idx.*(1, 2, 3)
    val xw: Idx.M[Int] = x.I.as[Idx.M[Int]](x => Idx.M.makeSized[Int](x.size).I(_ +~= x))
    
    // check
    xw.isInstanceOf[Idx.M[Int]].lp  // Prints: true
    xw.all.lp                       // Prints: ~(1, 2, 3)
    Definition Classes
    _Class
  3. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  4. def asInstanceOfTarget[T]: T

    Target cast

    Target cast

    This is same as regular asInstanceOf except it can derive target type from the context

    It can be useful when type is hard to come by

    type FOO >: Int
    
    val v : FOO = 1.asInstanceOfTarget
    Definition Classes
    _Class
  5. def Class: Itself.Class[A]

    Class constructor

    Class constructor

    Built-in constructor for Class

    "abc".I.Class.name lp  // Prints: java.lang.String
    Definition Classes
    _Class
  6. def drop(f: (A) ⇒ Boolean): Opt[A]

    Filtered out value option

    Filtered out value option

    If this does not pass filter function, this is returned as Opt

    Otherwise empty Opt.Void is returned

    5.I.drop(_ < 10).lp // Prints: Opt.Void
    5.I.drop(_ > 10).lp // Prints: Opt(5)
    Definition Classes
    _Class
  7. def hashIndex: Int

    Easy to read hash

    Easy to read hash

    Object hash is a long, hard to read number

    This method creates a static Lookup, where the long hash is stored with its sequential index. The index is used instead of real hash

    This mechanism is great for light debugging, and should not be use in production, because the Lookup table can grow to a point when it is a hurdle

    val myString = "string"
    
    "other1".I.hashIndex.lp // Prints: 1
    myString.I.hashIndex.lp // Prints: 2
    "other2".I.hashIndex.lp // Prints: 3
    myString.I.hashIndex.lp // Prints: 2
    "other3".I.hashIndex.lp // Prints: 4
    myString.I.hashIndex.lp // Prints: 2
    Definition Classes
    _Class
  8. def id: String

    Instance identifier

    Instance identifier

    Returns: Class.label + "@" + hashIndex

    "abc".I.id.lp  // Prints: java.lang.String@1
    Definition Classes
    _Class
  9. def ilk: Any.Ilk
    Definition Classes
    _Class
  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. def let(f: (A) ⇒ Boolean): Opt[A]

    Filtered value option

    Filtered value option

    If this passes filter function, this is returned as Opt

    Otherwise empty Opt.Void is returned

    5.I.let(_ < 10).lp // Prints: Opt(5)
    5.I.let(_ > 10).lp // Prints: Opt.Void
    Definition Classes
    _Class
  12. def letType[B](implicit t: ClassTag[B]): Opt[B]

    Typed option

    Typed option

    If this is an instance of provided type, this is returned as Opt value of new type

    Otherwise empty Opt.Void is returned.

    val a : Any = "abc"
    a.I.letAs[String].lp  // Prints: Opt(abc)
    a.I.letAs[Double].lp  // Prints: Opt.Void
    Definition Classes
    _Class
  13. def Opt: Opt[A]

    Non void Opt Constructor

    Non void Opt Constructor

    Creates an Opt with current value

    'null' or void values will create Opt.Void

    Voidness is tested with Any.isVoid

    var s: String  = null
    var p: Percent = \/
    
    s.I.Opt lp    // Prints: Opt.Void
    p.I.Opt lp    // Prints: Opt.Void
    
    s = "abc"
    p = 12
    
    s.I.Opt lp    // Prints: Opt(abc)
    p.I.Opt lp    // Prints: Opt(12.0%)
    Definition Classes
    _Class
  14. def repeat(times: Int): ~[A]

    Repeat as Stream

    Repeat as Stream

    Returns Stream with value repeated specified number of times

    'a'.I repeat 5 lp // Prints ~(a, a, a, a, a)
    Definition Classes
    _Class
  15. def to[THIS[_]](implicit to: Itself.To.Converter[THIS], i: Any.Ilk.Tag[A]): THIS[A]
    Definition Classes
    _Class
  16. def toArray(implicit ct: ClassTag[A]): Array[A]

    Create single element array

    Create single element array

    Definition Classes
    _Class
  17. def toString(): String

    String description

    String description

    Only differences with basic toString:

    • will not fail for null and print "null"
    • for void objects will print "void"
    • for scala singleton objects will omit hashCode (which does not make sense)
    "abc".I.toString.lp           // Prints: abc
    (null: String).I.toString.lp  // Prints: null
    "".I.toString.lp              // Prints: void
    Definition Classes
    _Class → Any
  18. def unfold(f: Mapping[~[A], A]): Stream[A]

    Lazy infinite stream

    Lazy infinite stream

    Lazily unfolds next value with a function taking all prior values

    1.I.unfold(_.last * 2).letNext(10).lp // Prints ~(1, 2, 4, 8, 16, 32, 64, 128, 256, 512)
    Definition Classes
    _Class

Operator

  1. def ~: ~[A]

    Create single element Stream

    Create single element Stream

    Definition Classes
    _Class
  2. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  3. final def ##(): Int
    Definition Classes
    Any
  4. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
Linear Supertypes
AnyVal, Any
Source: _Class.scala