Suppose we want social_link(user, social)
to return the user's social media link, how can we define that function so that the 'social' argument is used as a method on the user
argument?
i.e.
if social_link(user, "facebook")
, then it would run
user.facebook
or if social_link(user, "twitch")
, then:
user.twitch
and so on, with the key idea being that the function should take the string argument and call that string as a method on another object.
i.e something like
def social_link(user, social)
user.<social>
end
What is the syntax required to make this kind of function work?