Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

I run this script and got exception error

Anamika Rai
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 19, 2020
class Person {
String name
String toString() { name }
}
def John = new Person(name:'John')
def Ram = new Person(name:'Ram')
def p = John
def gs = "Name: ${p}"
assert gs == 'Name: John'
p = Ram
assert gs == 'Name: John'
john.name = 'Ram'
assert gs == 'Name: Ram'

1 answer

0 votes
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 23, 2020

You defined John with a capital J

But you try to set john.name with a lowercase j

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events