Yes you can - but it lacks the 'plausible deniability'. Especially if you have it in your frontend code. :)
After doing seo for 10 years, I assure you that plausible deniability will not give you an advantage. Google will punish your site and not listen to your arguments.
Well, presumably some people want to pose as Google to view content which is reserved to logged in members or bots, in which case the user agent is not advisable.. but indeed, IP address.