When my daughter and I struck out on our own, we often found the city hot and confusing, with little air-conditioning to be found (even in pricey restaurants) and service that could best be described as languid. One afternoon we set out to explore Ipanema, the beachside neighborhood of the famous song, figuring we’d wander through its markets and shops, maybe buy some flip-flops and get lunch. Nope: we stood at the front of restaurants whose maître d’s never came to seat us, jammed my ATM card into a series of machines that didn’t work and finally retreated back to the hotel pool in defeat.

But every time we were with members of our loose new network of Carioca friends, a far friendlier metropolis emerged, with rooftop hide-outs and delicacies we would not have known to order. Which is how we ended up the next day at Clube dos Caiçaras, a private swim club on the lagoon, or lagoa, nestled just inland of the Leblon beach. The temperature had hit an unspeakable 109 degrees (usually Rio tops out in the 90s in summer), and Christina’s friend Claudia had taken pity on us, inviting us to her club for refuge.

To get there, we were ferried across a small channel to a verdant floating enclave with tennis courts, swimming pools and views of Rio’s famous Christ statue. Claudia, a petite, thoughtful handbag designer, ordered me a caipirinha, and as we moved to the pool, I realized we were enjoying the ultimate Rio luxury: the ability to leave our bags carelessly on chairs without worrying about theft, an irresponsible act elsewhere in the city.

When we left the club, my daughter asked me what the word “exclusive” meant. It is hard to be in Rio these days and not think about money and class, in part because everyone sits around and talks about the soaring prices: the equivalent of $20 for cocktails, $40 for entrees and $80 for children’s bathing suits. You can still travel there without paying absurd prices — we stayed at two lovely hotels during the December holidays for less than $250 a night, and my daughter ate lots of cheese pastries for about a dollar a pop.

But Rio has become a city where people talk without irony about how cheap the apartments are in New York. And although the economic boom that lifted Rio also lowered poverty and expanded the country’s middle class, the gap between Brazil’s new ultrarich and its perpetual poor is impossible not to feel. The rooftop pool at the Philippe Starck-designed Fasano hotel, where rooms go for $750 and more per night, overlooks the democratic panorama of Arpoador Beach on one side, and on the other a favela, or urban shantytown, setting up a scene in which plutocrats relax while gazing at the homes of laborers.

I had been puzzling over whether and how to visit one of the favelas that climb the Rio hillsides. They are some of the most famous urban structures in the world: clusters of do-it-yourself housing that got by for decades with little official recognition from the Brazilian authorities, let alone police, garbage or sewage services. Since 2008, partly in an effort to bring down crime all over Rio in advance of the Olympics, the government has been “pacifying” favelas, clearing them of drug traffic, providing them with more services and making them far safer for visitors. If I didn’t go, I would miss seeing some of Rio’s most storied and fastest-changing neighborhoods.

But to ask around about visiting a favela is to be hit with torrents of conflicting advice: from Americans who warn that to do so is cheesy “poverty tourism,” and from bewildered middle- and upper-class Brazilians to whom favelas symbolize poverty and crime. “Cariocas don’t go,” Claudia told me at her swim club. “I never thought about it.” The State Department’s advisory on Brazil carries a stern warning about visiting favelas: “the ability of police to provide assistance, especially at night, may be limited ... be aware that neither the tour company nor the city police can guarantee your safety.” Some friends scoffed at that warning, calling it paranoid. Furthermore, they argued, the word “favela” is outdated; the more politically correct term is “comunidades,” or communities — and to stay away is to perpetuate the stigma that still hurts residents of those neighborhoods.