does Storing related records example have error?

i try to test the example in docs of Storing related records .

same code as the example,but it shows error

Catchable fatal error: Object of class Artist could not be converted to string in



It could be the quote ' copy then paste into your code


i have copied same code as the shows the error above.