Peter Allen and Barry Manilow have a lot to answer for. Copacabana’s long curved beach, with its nondescript high-rise hotels and apartments might look the goods in a touched-up post card or retro MTV clip, but on the ground, the tepid seawater is not that clean, nor is the sand, you trip over potholes in the pavement and I haven’t seen a wave all week. Add to that the fact that no “baby has smiled at me”, and they call this paradise? Heavily armed tourist police patrol the beach, supposedly for reasons of security.

The wider city, however, is extraordinary. The sheer physicality of its topography, with its high-density living, its frantic pulsing samba beats, its mega energy, its kamikaze bus drivers, its smouldering heat, its tropical downpours, its blizzardly cold beers, its poseurs and pretenders constantly parading along promenades, all make it feel like you’re living in a permanent fast lane with no drop-off zone in sight.

In one of the many little kiosks along the beach, a barman took a green coconut and held it upright in the palm of his hand and with a very sharp, shiny machete he lashed down at the top of the coconut and sliced off a section, then he did it again but from a different angle, taking another wedge off the top to make an opening, and if the machete slipped down the side of the coconut, his hand would have been separated from his wrist, but this didn’t happen. After that, he added some ice cubes and a straw and charged three real (about $2) for a coco drink. It was not very refreshing, and so I only ordered Caipirinhas after that (smashed limes, sugar syrup and cane liquor, shaken over ice) because they are extremely refreshing in the heat, but more than four can make you a bit tiddly, which is why it’s wise to have some acaraje (spicy prawn croquettes) as well, for reasons of sobriety.

In the favela slums, which account for more than 20% of Rio’s official metropolitan population of about 12 million, drug barons and their armies keep the peace (and everything else) because the police don’t go there much, unless a gang war breaks out, which is usually for control of territory.

The last war was in 2004 and it lasted 40 days. Only marijuana and cocaine is traded; there is little or no heroin at all. The drug boss of the largest slum (120,000-plus residents) has a nickname that translates from the Portuguese to baby in English; this, according to Simone, the guide of the excellent favela tour I took. Apparently Baby moves house every week or so, for reasons of security.

Rio’s Maracana football stadium holds more than 100,000, and I went to see a game between two arch-rival teams in the local state league that was played in scorching temperatures, and fans where kept apart by polizia with batons the size of baseball bats. (These were different police to the ones on the beach beat.) You had to lift up your shirt at the security check point on entering to ensure you weren’t carrying firearms or other weapons. Most males (and many females) took their shirts off, and left it off anyway, which had horrendous consequences on the trip home as we all squeezed, armpit to armpit into the metro. During the game, fans with drums and horns and trumpets and trombones made more noise than a symphony orchestra, and sounded much better. Thankfully, the section I ended up in was the victor on the day (3-0), and it was the largest contingent by far, so I felt safe because, as they say, there is security in numbers.

But for a brief period last Saturday night, I could have done with some security of my own. He looked like most other disabled beggars you might see in any city, crouched cross-legged on the pavement with a hand and face turned upward pleading for charity or small change. He had very dark skin and a scar on his cheek, like Omar’s in The Wire. He was bare foot, his head closely shorn, clothes soiled and torn.

This was on Copacabana’s beachfront Ave. Atlantica — probably the busiest thoroughfare in Rio — albeit on the quieter side of the street, just off the car-parking stretch and in between major hotels, where the street lighting was slightly dim, and only occasional pedestrians would wander, most likely en route to their accommodations, as I was. Six lanes of teeming traffic and a generous median strip separated us from the promenade along the actual beach, with its tatty kiosks, piles of coconuts, bright lights and constant stream of sunburnt humanity in various stages of undress. It had cooled down to 30 degrees and was very sultry.

Others just in front of me walked right by the beggar, as I was about to when he “miraculously” got to his feet and grabbed me by the upper arm in a grip that was not normal or acceptable. The sizeable steak knife he quickly produced in the other hand with menace and aggression demanding money looked like it had cleaned fish that same day, as I think I saw scales reflected in the minimal light, and some of the blade’s serrated teeth seemed rusted or discoloured. Later, I thought this might have been blood, but at the time this did not occur to me. I did not hand over any of the $40 cash I had secreted in my pocket, but just kept saying “no” in response to each more aggrieved demand.

I do not know why I responded this way; it is something you do not rehearse, but it is a risk when travelling solo in Rio that lurks in the back of your mind, like the constant presence of the towering basalt bluffs that dominate the city’s dramatic skyline. The reality, mostly, is that these young men born into abject poverty and with very little prospects of escaping the favela slum, don’t want to cause grievous bodily harm per se; they just want your money, and quickly.

“No money,” I kept saying, which he seemed to understand because he repeated it too with each threatening poke of the blade in the direction of my stomach. Then, he looked away suddenly (at something or someone approaching, I don’t know?), but a flicker of recognition or resignation flashed across his face, and he let go of my arm, hurried to a fence a few metres away, picked up a small plastic sac, and disappeared into the night. The whole episode probably lasted less than 10 seconds, and I still had my money. But it was never about the money. And I still can’t explain why I responded in that way.

Speaking of money, 15 years ago, it didn’t go very far in Brazil; inflation was running at about 750%. Rio must have been a desperate town back then. (The central bank’s current headline interest rate 8.75%.) From free-floating the currency and privatising state-controlled firms in the mid 90s, to granting more autonomy to the central bank and reducing arcane protectionist policies, the country has not only turned the inflation corner and added stability to the political vocabulary, but it now lends money to the IMF, which is a complete turn-around in the space of little more than a decade, when the same institution attached tough conditions on loans to a near-bankrupt Brazil.

Which seems a bit ironic today, given Brazil’s increasingly affluent middle class loves to spend. Just down the road from Rio in Sao Paulo, Tiffany & Co has more jewellery stores than any other city in the world. And rich or poor, everyone seems to wear Havaianas. But it is a national economy still very reliant on commodities, having ridden the heights of the recent boom much like many of Australia’s mineral exporters. Then there’s the massive informal “black” economy, still rife due to expensive and complex tax and labour laws that effectively discourage setting up a formal company in the first place. My beggar-come-mugger was definitely part of the black economy.

Shaken, but not stirred following my assailant’s rushed departure, I headed in the opposite direction in search of those heavily armed polizia. No sign of any. Went back to the hotel, but waited for a family to head in the same direction first, then “lurked” close behind, for reasons of security. And for the remaining 36 hours in Rio, I was looking at every man approaching or passing me in the street and seeing if something was hidden in his hand or on his face, and I turned my back constantly, on the lookout for anyone intent on sinister deeds. It was not the ideal way to end my stay.

A desire to ride the last remaining streetcar across the aqueduct through the crumbling, bohemian grandeur of Santa Terasa all the way up winding Rua Joaquim Murtinho to lunch at Largo Dos Guimaraes, was in fact the ideal way to end my stay. But this was a Sunday and guidebooks (I discovered later) say to avoid Santa Teresa on weekends and particularly if alone, but if you do go, stick with a group but be wary of pairs of youths on mopeds. It’s a poor area, which ironically is probably safer at night when the streets come alive with the sounds and beats of samba. Coincidentally, infamous British train robber Ronnie Biggs sought refuge here during his years of exile on the run. But I was spooked by the beggar-come-mugger incident the night before and settled instead on the slightly more safe option of a Sunday morning ferry jaunt across Guanabara Bay to Niteroi.

Beyond this incident, however, the roads, the beaches, the sites, the public transport, the crumbling footpaths, the thronging metropolis, all feel crowded and stretched to bursting point now; so how will Rio cope with a Football World Cup (2014) and the Olympic Games just two years later? The city authorities and polizia may have to call a truce and enlist the drug barons’ armies, “for reasons of security”. But would I recommend Rio as a destination? Absolutely. Just take heed of the precautions, go with a companion possibly (if that’s not too dire) and make sure it’s a weekday you choose to ride that streetcar named Desire.