It happens more often than you may think. Sailboats are designed to allow the lightening to travel the mast into the water relatively safely without frying electronics.
Without doing a google research on it, I'd feel safer in a boat than under a tall tree. ( Years ago I did a lot of freshwater sailing, couldn't always make port before a storm, so stayed away from the mast until it was over :lol: ).