There are different ways to steal ips... one way is if you click on a phishing link that steals your browser's information like ip, your country, your city, etc.
other way of doing that is complicated; If you both guys are connected to the same server, they will use a software which tells you every ip connected to your computer like when you send a message to someone on facebook or like if you and the other person are connected to the same server in-game...
But you don't need to worry about the person who told you he knows your ip... it will be changed if you restart your router/internet... hacking someone's computer through ip over the internet is a complicated task