Hey there, is there a quick Ruby (or Rails) expression that returns nil if an object does not have a value ?
For instance, if self.name is null in database, it should return nil. If it's a string, it should return it. I'm thinking of unless, but maybe there is something better.
Also, if you have a function like get_profession(type), and type can be "first", "second" or "third", what would be an elegant way of inquiring self.first or self.second or self.third(according to type parameter) and return nil unless self.first(or other type) has a string value ?
As you see, the second question closely relates to the first.