Thank you for the question Linh!
It will depend on your company culture and also your position on how you handle the situation. I would say the majority of the time you should go through the proper channels, such as, your manager or HR and make sure you have something written such as an initial email or a follow up email after you verbally spoke.
This previous co-worker who was rude to me in this story was often rude and disrespectful to women at work, but you may come across some men who might just not have a lot of experience interacting with women.
I was often the only woman in meetings and some of the men would tell very sexual jokes or stories that objectify women and it was normal to them, because they did it every meeting before I joined. I decided AFTER the meeting to pull one of the offenders aside and speak to him one on one. I let him know that it made me feel uncomfortable when they told those jokes and he was very apologetic and genuinely seemed to have no idea it could be offending me.
Good luck on moving into tech it’s a lot of fun and I’m SO happy I made the change!