In c# I can write code such as this (I ran it Linqpad 5):
void Main()
{
new Test { Property1 = 100 }.Dump();
Console.WriteLine(nameof(Test.Property1));
}
class Test
{
public int Property1 { get; set; }
override public String ToString()
{
return $"{nameof(Property1)}={Property1}";
}
}
Is there a scala equivalent of nameof?
Thanks
In Scala it can be done by a (macro) library instead of needing special language-level support. There is one at https://github.com/dwickern/scala-nameof.
There is no any similar methods in scala as of C#, If you really want the function than you can use scala-reflection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With