final class UniversalOps[A] extends AnyVal
- Alphabetic
- By Inheritance
- UniversalOps
- AnyVal
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new UniversalOps(a: A)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
##(): Int
- Definition Classes
- Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- Any
- def applyIf[A0 >: A](predicate: (A) ⇒ Boolean)(f: (A) ⇒ A0): A0
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- def checkNotNull(msg: String): A
- def debugMacro: A
-
def
discard: Unit
Explicit syntax to discard the value of a side-effecting expression.
Explicit syntax to discard the value of a side-effecting expression. Useful when
-Ywarn-value-discard
compiler option is enabled.- Annotations
- @silent()
-
def
getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def matchOpt[B](pf: PartialFunction[A, B]): commons.Opt[B]
- def opt: commons.Opt[A]
- def option: Option[A]
-
def
setup(code: (A) ⇒ Any): A
Alternative syntax for applying some side effects on a value before returning it, without having to declare an intermediate variable.
Alternative syntax for applying some side effects on a value before returning it, without having to declare an intermediate variable. Also, using
setup
confines the "setting-up" code in a separate code block which has more clarity and avoids polluting outer scope.import javax.swing._ // this entire expression returns the panel new JPanel().setup { p => p.setEnabled(true) p.setSize(100, 100) }
Example: -
macro
def
showAst: A
Prints AST of the prefix in a compilation error.
Prints AST of the prefix in a compilation error. Useful for debugging macros.
-
macro
def
showRawAst: A
Prints raw AST of the prefix in a compilation error.
Prints raw AST of the prefix in a compilation error. Useful for debugging macros.
- macro def showRawType: A
- macro def showSymbol: A
- macro def showSymbolFullName: A
- macro def showType: A
- macro def showTypeSymbol: A
- macro def showTypeSymbolFullName: A
-
macro
def
sourceCode: String
Returns source code of the prefix expression as string, exactly as in the source file.
Returns source code of the prefix expression as string, exactly as in the source file. Strips common indentation. Requires -Yrangepos enabled.
- def thenReturn[T](value: T): T
-
def
toString(): String
- Definition Classes
- Any
-
def
unboxedOpt[B](implicit unboxing: Unboxing[B, A]): commons.Opt[B]
Converts a boxed primitive type into an
Opt
of its corresponding primitive type, convertingnull
intoOpt.Empty
.Converts a boxed primitive type into an
Opt
of its corresponding primitive type, convertingnull
intoOpt.Empty
. For example, calling.unboxedOpt
on ajava.lang.Integer
will convert it toOpt[Int]
. -
def
uncheckedMatch[B](pf: PartialFunction[A, B]): B
To be used instead of normal
match
keyword in pattern matching in order to suppress non-exhaustive match checking.To be used instead of normal
match
keyword in pattern matching in order to suppress non-exhaustive match checking.Option(42) uncheckedMatch { case Some(int) => println(int) }
Example: - macro def withSourceCode: (A, String)
-
def
|>[B](f: (A) ⇒ B): B
The "pipe" operator.
The "pipe" operator. Alternative syntax to apply a function on an argument. Useful for fluent expressions and avoiding intermediate variables.
someVeryLongExpression() |> (v => if(condition(v)) something(v) else somethingElse(v))
Example: