WASHINGTON — Supreme Court Justice Sonia Sotomayor has said that the seed for what has become her latest children's book was planted the day a woman called her a drug addict.

Sotomayor, who was diagnosed with diabetes at age 7, had gone to the bathroom of an upscale New York restaurant to give herself an insulin shot. She was in her 30s but hiding her diabetes. Another diner came in and saw her and later, as Sotomayor was leaving the restaurant, she heard the woman tell a companion: "She's a drug addict."

Outraged, Sotomayor confronted her, explaining that the shot was medicine, not drugs: "If you don't know something, ask, don't assume," Sotomayor said.

From that exchange comes the title of Sotomayor's latest book, "Just Ask! Be Different, Be Brave, Be You," released Tuesday and intended for kids age 4 to 8. The book introduces readers to children who face what Sotomayor calls "life challenges" as they work together to create a garden rich with different flowers and plants, a metaphor for their own differences.

A young Sotomayor begins the book by talking about her diabetes and encouraging children to ask about other kids' differences. Other children introduce their own challenges, including attention-deficit/hyperactivity disorder, autism, blindness and Down syndrome.

"Differences provide not just beauty in life, but they're important to the quality of the world we live in. It's richer because of our differences. We're not lesser because of it. We're stronger because of it. My book celebrates the many ways in which kids and adults are different and do things differently," Sotomayor said in an interview ahead of the book's publication.

Sotomayor, who was appointed to the Supreme Court by President Barack Obama in 2009, said she has wanted to write the book "forever" and that she was also motivated by hearing the stories of friends who have children with chronic conditions. One child, she said, was separated from other students at school when it was time to eat because he had a host of allergies. Another friend's child who has Tourette's syndrome and therefore tics she can't control was told she was badly behaved by a shopper at a store.

"Those experiences struck me as a reason for me to go ahead with the book that had been in my head," Sotomayor said. She said she was particularly touched by a child in her life who, after learning about how Sotomayor had confronted diabetes, set up a study area in her room and said she wouldn't let her own challenges stop her.

Sotomayor, the Supreme Court's first Latina justice, said she believes readers will see themselves or someone they know in her book. And she noted that her book's children are culturally and ethnically diverse because "life challenges are not limited to one kind of people."

The book is illustrated by Rafael López, who himself has dyslexia and a son with high-functioning autism. A child named Rafael in the book who has asthma is painting rocks, a subtle nod to the illustrator. Another subtlety, the book's character Vijay, who is deaf, is signing the word "grow" to a newly planted tree.

Sotomayor has come out with a string of books over the last year. Her memoir, "My Beloved World," came out in 2013. In 2018, she released a version for middle school readers and a picture book . Each of her books is also available in Spanish.

Sotomayor said for now she's taking a book-writing break, but she's making several book-related appearances before the court ends its summer recess and begins hearing arguments again Oct. 7.

Sotomayor said it's important to her to continue to speak to and write for children. She has ideas for future books, likely related to civics, she said.

"I truly believe that if I can inspire the younger generation to see themselves as positive agents for change...that I will leave a more lasting legacy than what I can do as a judge," she said.

Follow NBC Latino on Facebook, Twitter and Instagram.