Scientists conditioned the worms so that when salt was present they realised that they would be starved. Over time, the worms moved away from the salt. However when the salt was present at the same time as a mate, the male worm still moved towards the mate. In contrast, hermaphrodites moved away from the salt even when a mate was present.