@@ -14,15 +14,17 @@ Usage
1414=====
1515
1616Add the library as "provided", because it's only needed during compilation and not at runtime:
17-
1817``` sbt
1918libraryDependencies += " com.github.dwickern" %% " scala-nameof" % " 3.0.0" % " provided"
2019```
2120
22- Now you can use ` nameOf ` to get the name of a variable or class member :
23- ``` scala mdoc:nest
21+ And import the package :
22+ ``` scala mdoc
2423import com .github .dwickern .macros .NameOf ._
24+ ```
2525
26+ Now you can use ` nameOf ` to get the name of a variable or class member:
27+ ``` scala mdoc:nest
2628case class Person (name : String , age : Int )
2729
2830def toMap (person : Person ) = Map (
@@ -41,8 +43,6 @@ def toMap(person: Person) = Map(
4143
4244To get the name of a function:
4345``` scala mdoc:nest
44- import com .github .dwickern .macros .NameOf ._
45-
4646def startCalculation (value : Int ): Unit = {
4747 println(" Entered " + nameOf(startCalculation _))
4848}
@@ -57,8 +57,6 @@ def startCalculation(value: Int): Unit = {
5757
5858Without having an instance of the type:
5959``` scala mdoc:nest
60- import com .github .dwickern .macros .NameOf ._
61-
6260case class Person (name : String , age : Int ) {
6361 def sayHello (other : Person ) = s " Hello ${other.name}! "
6462}
@@ -75,8 +73,6 @@ println("sayHello")
7573
7674You can also use ` nameOfType ` to get the unqualified name of a type:
7775``` scala mdoc:nest
78- import com .github .dwickern .macros .NameOf ._
79-
8076println(nameOfType[java.lang.String ])
8177```
8278``` mdoc:nest
@@ -87,8 +83,6 @@ println("String")
8783
8884And ` qualifiedNameOfType ` to get the qualified name:
8985``` scala mdoc:nest
90- import com .github .dwickern .macros .NameOf ._
91-
9286println(qualifiedNameOfType[java.lang.String ])
9387```
9488``` mdoc:nest
0 commit comments