Skip to content

Commit 351be09

Browse files
committed
import once at the top
1 parent da58a32 commit 351be09

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ Usage
1414
=====
1515

1616
Add the library as "provided", because it's only needed during compilation and not at runtime:
17-
1817
```sbt
1918
libraryDependencies += "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
2423
import 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
2628
case class Person(name: String, age: Int)
2729

2830
def toMap(person: Person) = Map(
@@ -41,8 +43,6 @@ def toMap(person: Person) = Map(
4143

4244
To get the name of a function:
4345
```scala mdoc:nest
44-
import com.github.dwickern.macros.NameOf._
45-
4646
def startCalculation(value: Int): Unit = {
4747
println("Entered " + nameOf(startCalculation _))
4848
}
@@ -57,8 +57,6 @@ def startCalculation(value: Int): Unit = {
5757

5858
Without having an instance of the type:
5959
```scala mdoc:nest
60-
import com.github.dwickern.macros.NameOf._
61-
6260
case class Person(name: String, age: Int) {
6361
def sayHello(other: Person) = s"Hello ${other.name}!"
6462
}
@@ -75,8 +73,6 @@ println("sayHello")
7573

7674
You can also use `nameOfType` to get the unqualified name of a type:
7775
```scala mdoc:nest
78-
import com.github.dwickern.macros.NameOf._
79-
8076
println(nameOfType[java.lang.String])
8177
```
8278
``` mdoc:nest
@@ -87,8 +83,6 @@ println("String")
8783

8884
And `qualifiedNameOfType` to get the qualified name:
8985
```scala mdoc:nest
90-
import com.github.dwickern.macros.NameOf._
91-
9286
println(qualifiedNameOfType[java.lang.String])
9387
```
9488
``` mdoc:nest

0 commit comments

Comments
 (0)