You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Dani Mező <da...@gmail.com> on 2023/01/19 13:01:50 UTC

ToString does not seem to work for me

Hi fellow devs,

I ran into a problem, where ToString() does not work for me, I'd like to
post here before I open a bug ticket, I am sure I did something wrong.
My classes below.

Main.groovy:

class Main {
    static void main(args) {
        println(new Card(name: "hey"))
    }
}

Card.groovy:

import groovy.transform.ToString;

@ToString
class Card {
    String name;
}

My output:

Card@43f02ef2

I expected the class to be pretty printed into my console, but that is not
the case.
What do I do wrong?

I am building with
Intellij 2020.3.2
Groovy 3.0.7
OpenJDK 15.0.2

Any suggestions?

Cheers, Daniel

Re: ToString does not seem to work for me

Posted by Narahari Lakshminarayana <it...@gmail.com>.
Did u compile with groovyc or javac ?

Please post all sources java and groovy.


I am confused.

On Thu, Jan 19, 2023, 08:04 Dani Mező <da...@gmail.com> wrote:

> Ahhhhh, nevermind, my Card.groovy was a Card.java, and ToString just had
> no effect I guess.
>
> Dani Mező <da...@gmail.com> ezt írta (időpont: 2023. jan. 19., Cs,
> 14:01):
>
>> Hi fellow devs,
>>
>> I ran into a problem, where ToString() does not work for me, I'd like to
>> post here before I open a bug ticket, I am sure I did something wrong.
>> My classes below.
>>
>> Main.groovy:
>>
>> class Main {
>>     static void main(args) {
>>         println(new Card(name: "hey"))
>>     }
>> }
>>
>> Card.groovy:
>>
>> import groovy.transform.ToString;
>>
>> @ToString
>> class Card {
>>     String name;
>> }
>>
>> My output:
>>
>> Card@43f02ef2
>>
>> I expected the class to be pretty printed into my console, but that is
>> not the case.
>> What do I do wrong?
>>
>> I am building with
>> Intellij 2020.3.2
>> Groovy 3.0.7
>> OpenJDK 15.0.2
>>
>> Any suggestions?
>>
>> Cheers, Daniel
>>
>

Re: ToString does not seem to work for me

Posted by Dani Mező <da...@gmail.com>.
Ahhhhh, nevermind, my Card.groovy was a Card.java, and ToString just had no
effect I guess.

Dani Mező <da...@gmail.com> ezt írta (időpont: 2023. jan. 19., Cs,
14:01):

> Hi fellow devs,
>
> I ran into a problem, where ToString() does not work for me, I'd like to
> post here before I open a bug ticket, I am sure I did something wrong.
> My classes below.
>
> Main.groovy:
>
> class Main {
>     static void main(args) {
>         println(new Card(name: "hey"))
>     }
> }
>
> Card.groovy:
>
> import groovy.transform.ToString;
>
> @ToString
> class Card {
>     String name;
> }
>
> My output:
>
> Card@43f02ef2
>
> I expected the class to be pretty printed into my console, but that is not
> the case.
> What do I do wrong?
>
> I am building with
> Intellij 2020.3.2
> Groovy 3.0.7
> OpenJDK 15.0.2
>
> Any suggestions?
>
> Cheers, Daniel
>