开发者

Returning class type in ruby

I need a function that checks the namespace of the argument, and returns the class type

for example:

checkType(id)
   if id starts with "p:"
   return <Cl开发者_StackOverflow社区ass Type>
end

I do not have an instance to use when checking the type of the id


It's kind of a lame, hackish approach, but if you know what the IDs are that you're looking for, and there's not too many, you could create a hash mapping of ID to ClassType.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜