27
Wombat
2y

$child = new Child();
$child->gender = 'female';
$wombat->children[] = $child;

Comments
  • 3
    That's funny how this API allows for an empty constructor
  • 6
    @hippolyte Well it doesn't say sex ;)
  • 4
  • 3
    @illuminaughty Bruh
  • 9
    Congrats @wombat,
    May your sleeping habits be destroyed in the coming months.

    @hippolyte that's because the first 300 lines, default everything out with rand() instead of accepting arguments.

    The real question is, What was the gender before it was reassigned.
  • 1
    @C0D4 defaults to null.
  • 3
    @nitnip null?
    This is php, and given it's a string assignment I would bet it was "" at best.
  • 1
    @C0D4 by default properties have no type and default to null. If it was a typed property, PHP won't allow you to access it before it's initialized.
  • 4
    Princess in process...
  • 4
    Congrats to you and your Family 🎊❤️🤝🎉🙌🙏
  • 6
  • 3
    @illuminaughty dude that was just because he wanted to spell it out for you.

    $parent->children[] = new Child();

    The conductor of the Child class randomly assigns gender. In the woke version gender is a method that returns a fluid gender object with a scale. PHP is flexible that way.
  • 2
    I would suggest the Laravel syntax would be more like

    $wombat->createDaughter()

    Where

    function children(): HasMany
    {
    return $this->hasMany(Child::class);
    }

    function createDaughter(): void
    {
    $this->children->create([
    'gender' => 'female',
    ]);
    }
  • 2
    Congrats.
  • 2
    @kamen thank you very much.
  • 3
    Congratulations.

    Vacation pays off (Easter holidays)... I didn't understand why we needed to know that an animal gave birth.

    Took a long time for me to figure that out.

    Happy parent hood, remember silence is deadly.
  • 4
    @IntrusionCM thanks for the kind words. Becoming father for the third time makes things routine. Still it's a whole new experience with two bigger children wanting your attention, too.
  • 2
    @Wombat the more the merrier....

    :)

    Then I hope that everyone gets along nicely and you can enjoy parenthood as much as possible.
  • 2
    @wombat

    fmt.Println(len(wombat.Children))

    // p.S. Congrats on your new array item!
  • 1
    Congrats @Wombat!
  • 1
  • 1
    Congratulations!

    I would have appended instead of assigning a single object to an array but maybe I don’t know that syntax
  • 1
    hell yeah! So many congratulations are in store.
  • 2
    @Wisecrack @AndroidJester @rov3rand0m thank you very much. She's over a month now... Still acting like a baby.
Add Comment