The Magician's Code - Part One

HIMYM episode 7x23 (159)

The Magician's Code 6
First aired:
May 14, 2012
Pamela Fryman
Jennifer Hendriks

Images (0)

While Marshall is in Atlantic City with Barney, Lily goes into labor, leaving him desperate to make it back to New York before the baby is born. Meanwhile, Ted and Robin try to distract Lily during her painful contractions.


Continuing from the previous episode, Lily has gone in labor, while Marshall is in Atlantic City with Barney. When Ted and Robin arrive at the apartment to take her to the hospital, she tells them that she can't get admitted unless her contractions are four minutes apart. She then asks Ted and Robin to tell her stories to distract her from the pain. They later take her to the hospital when she is ready.

Since Marshall and Barney are both intoxicated and can't drive back to New York, they try to find other ways to get back. Barney vows to take Marshall back if he promises the middle name of his son will be "Wait-for-it" and Marshall agrees. Barney then finds two seats on a senior citizens' bus to New York, but they later realize that the bus is going to Buffalo, not New York City. Marshall begs the driver to take a detour to New York City so that he can get to the hospital, but the driver tells him that he is not allowed to make a stop, unless it is an emergency. However, after Barney gives an impassioned speech in Marshall's defense, a few passengers fake a heart attack, forcing the driver to make a stop and Marshall and Barney finally reach the hospital when Lily is ready to push.

While in the waiting room, Ted and Robin make up, and become friends again. Marshall then comes out of the delivery room, telling them that he is a dad. The gang then gathers around the baby and Lily, who tells them that the baby is named Marvin, after Marshall's dad, with his full name being Marvin Wait-for-it Eriksen, fulfilling Barney's conditions for getting Marshall back to New York. Everyone then welcomes Marvin into the world.

Continue reading on the next page


  • Ted has made a website referring to Lily giving birth (, with Lily getting angry about him emailing it to everybody. Lily was previously angry at Marshall for making videos to document events, as noted in the The Sexless Innkeeper​.
  • Marshall is seen wearing his "Mad at Lily Shirt," with the words: 'Marshall and Steph 4eva'.
  • Lily does not want her father anywhere near her during medical emergencies. Lily's strained relationship with her father was first revealed in Slapsgiving 2: Revenge of the Slap​.
  • Robin's story about being sent to live on a farm by her father after kissing a boy is an expansion of her story in Happily Ever After​.
  • Robin says that she has delivered twelve babies, one of which was human. This is a reference to the on-air delivery she did on her show Come On, Get Up New York! in The Front Porch​.
  • The scene where Dr. Sonya says "Lily, if you don't push, I'll shove this baby up your throat and pull it out of your mouth" was already shown in The Stinson Missile Crisis​. The scene in that episode showed that Lily was far more sweaty, although it can be attributed to her perspective of the birth.
  • A sign saying "No Motorcycles On The Casino Floor" was put up at the casino in Atlantic City, because of Barney. This is a similar incident to the one in Disaster Averted; the sign in front of MacLaren's saying: "Absolutely No Boogieboarding."
  • Barney previously mentioned his distaste of women from Buffalo, New York in Sweet Taste of Liberty​.
  • It is shown that Marshall has smoked his last cigarette in Atlantic City as stated in Last Cigarette Ever.
  • The scene when Marshall becomes drunk in Atlantic City and says "All Hail Beercules" was already shown in The Naked Truth​.
  • Robin's excited reaction to the homeless man fighting the cab driver shows her infatuation with fights. This was first shown in The Fight​.

Future References (Contains Spoilers)


For a listing of all images on the wiki tagged as being from this episode, see Category:The Magician's Code - Part One images.

Memorable Quotes

Dr Sonya (about Robin): Get that THING out of here! Weak women disgust me.

Dr. Sonya: Lily, if you don't push, I will shove this baby up your throat and pull it out of your mouth!

Barney: Tell them the full name.
Lily: Marvin "Wait-for-it" Eriksen.

Marshall: The middle name is wait-for-it...
Lily: (in labor) I can't wait anymore!
Marshall: No, the middle name is Wait-for-it.
Lily: (in labor) Oooooh! That is the coolest name of all time!

Robin: I know things have been weird between us for a last few months. But Marshall and Lily are having a baby.
Ted: Yeah.
Robin: And, you know, I want this baby to be born into a world where we're okay. So...friends?
Ted: I love you, Robin
Robin: ... (frowns)
Ted: Kidding.

Notes and Trivia

Goofs and Errors

  • Robin says she was thirteen when her father caught her kissing a boy, but in Happily Ever After she says she was fourteen.
  • During the scene when Barney is talking to the bus driver you can see the wire of his mic covered behind the ducky tie.
  • During the story of the Cuban Sandwich Crisis, Robin is show with her Blackberry Touch. However, the events of the story occur when Robin and Ted were dating in 2006, well before that phone was made. 
  • In the "Where Does That Door Go?" story, Barney and Robin make flirtatious gestures, implying that they were a couple. However, both Robin and Lily had different hairstyles at that time. 
  • The Gummy Bears Barney holds up before Marshall comes out to announce that Marvin is born are clearly CVS store-brand gummy bears, which wouldn't be in a vending machine. 

Allusions and Outside References

  • Marshall speaks like Yoda while being drunk.
  • Robin claims she spent some private time with Neil Young at her bedroom.
  • Marshall imagines an ATM screen as actually showing scenes from the 1986 video game The Legend of Zelda.
  • Ted reminds Lily of the gang trick-or-treating on Halloween as characters from the The Breakfast Club but they all dress as John Bender.
  • Barney tries to pick up women as the Terminator. He wonders why he is unable to pick up any women in biker attire and later tries doing it nude, impersonating Arnold Schwarzenegger's voice.
  • Bus driver tells Barney to "sit down, watch Cocoon 2 and shut up" - a reference to "Cocoon", the movie that Lloyd Dobler (John Cusack) shows to the tenants at elderly home in 1989 movie "Say Anything".
  • Elderly passengers on the bus back to New York stand up one by one and say "I'm having a heart attack" in the same manner that the slaves declared "I'm Spartacus" in the 1960 film "Spartacus".
  • Lily mentions that Marshall wearing his cursed pants as part of a suit looks like a little kid's imaginary friend, an allusion to Drop Dead Fred, movie with Phoebe Cates as main character, also the chinese store resembles that one from Gremlins, another movie with Cates.


Other Notes

  • Along with The Magician's Code - Part Two, this marked the first time in the series where two episodes were aired on the same night as part of a season finale. The next time this would happen is in Season 9 when the series finale consisting of two episodes (Last Forever - Part One and Last Forever - Part Two) would be aired back-to-back.
  • The chinese note Marshall finds in his pants says 翼商场先生 (direct translation is Wing Mall Mister) or Mr. Ming's Store.
  • This episode was originally going to be called Tell Me a Story.
  • This episode is the second of 2 episodes in which the phrase "busting apple bags" is used. The first is in Drumroll, Please.
  • In this episode Barney is seen saying 'great news from down the hall' before saying something completely unrelated to the birth as in Last Forever - Part Two.


  • Chris Elliott - Mickey Aldrin
  • Vicki Lewis - Dr. Sonya
  • Caine Sinclair - Joe
  • Nikki Stanley - Kate
  • Paul Eliopoulos - Homeless Man
  • Max Daniels - Cab Driver
  • Francesca Capaldi - 7-Year-Old Lily
  • Ken Takemoto - Elderly Chinese Man
  • Bobby C. King - Security Guard
  • Mike Grief - Bus Driver
  • Katie Enright - Nurse
  • Brenda Ballard - Fran
  • Elliot Goldwag - Alfred
  • Vivian Smallwood - Leila
  • Natalie Padilla - Banana Peel Girl
  • Scott Workman - Security Guard #2
  • Brooke D'Orsay - A girl whom told Barney and Marshall they couldn't get a cab in Atlantic City because of "the big thing"


Featuring Craig Thomas, Chris Harris and Sue Federman.


  • This episode, along with The Magician's Code - Part Two, was viewed by 8.49 million people. [1]
  • Donna Bowman of the AV Club gave the episode a B, stating that much happened in the episode even if there were contradictions along the way while the outcomes of certain events are attempts at misdirection. [2]
  • Entertainment Weekly's Michelle Profis stated the episode does not leave anything for the audience to contemplate before the next season but left some emotional moments such as the baby being named after Marshall's father. [3]
  • Ethan Alter of Television Without Pity gave the episode a C+. [4]
  • Robert Canning of IGN gave the episode 8.5 out of 10. [5]
  • The St. Petersburg Comic Review gave this episode 7.5 out of 10 stars. "...and Marshall's drunk in Atlantic City. ... of course."


External Links

Previous episode
Good Crazy
The Magician's Code - Part One
(all episodes)
Next episode →
The Magician's Code - Part Two