Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atom "A Little Reflection", object/ trait Name #67

Open
waij opened this issue Dec 20, 2016 · 1 comment
Open

Atom "A Little Reflection", object/ trait Name #67

waij opened this issue Dec 20, 2016 · 1 comment

Comments

@waij
Copy link

waij commented Dec 20, 2016

In atom A Little Reflection you introduce an object and a trait Name to add a toString to any class. It is unclear to me why the object is needed. This code without an object seems to work equally well:

trait Naam {
override def toString =
currentMirror.reflect(this).symbol.toString.replace('$', ' ').split(' ').last
}
class Noot extends Naam
println((new Noot).toString) // ---> 'Noot'

@waij
Copy link
Author

waij commented Dec 20, 2016

Your example on page 268 runs just fine:

class Solid2(val size:Int) extends Naam { //...
s2 is "Solid2(47)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant