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

Joke Objects Error in book - p. 542 #14

Open
chasinglucid opened this issue Aug 29, 2018 · 2 comments
Open

Joke Objects Error in book - p. 542 #14

chasinglucid opened this issue Aug 29, 2018 · 2 comments

Comments

@chasinglucid
Copy link

chasinglucid commented Aug 29, 2018

This;

` $author = $this->authorsTable->findById($joke->authorId);

  $jokes[] = [
    'id' => $joke->id,
    'joketext' => $joke->joketext,
    'jokedate' => $joke->jokedate,
    'name' => $author->name,
    'email' => $author->email,
  ];

`

Should be:

` $author = $this->authorsTable->findById($joke->authorId);

  $jokes[] = [
    'id' => $joke->id,
    'joketext' => $joke->joketext,
    'jokedate' => $joke->jokedate,
    'name' => $author->name,
    'email' => $author->email,
    'authorId' => $author->id
  ];`

Otherwise, you get error messages where Edit & Delete should be. (It's correct in the sample code.)

@NarniaT
Copy link

NarniaT commented Aug 30, 2018

I think it's much better if you also mention the place(in the code) you have spotted this.
IMHO, many of such issues are left wrong deliberately as the authors have only been "explaining" an approach(and not choosing it) and then on some next pages, they have introduced a new(and better) option. To make sure this part of the program has continued to exist until the final version, you can check the final-website branch and see whether it's still there.
(I'm not saying this issue is wrong at all, I've just said what I've experienced).

@chasinglucid
Copy link
Author

chasinglucid commented Aug 30, 2018

Right at the top of page 542, it says:

The error occurs because $author and $joke are no longer arrays. This is a
simple fix: change the syntax that reads from an array to use the object syntax:

Plus, as I said, it is correct in the sample code, which the bottom of the page says. It's just missing that one item in the $jokes array.

I know because I've read through the section 3x because I don't understand it.

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

2 participants