开发者

Returning class type in ruby

开发者 https://www.devze.com 2023-01-04 03:04 出处:网络
I need a function that checks the namespace of the argument, and returns the class type for example: checkType(id)

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

精彩评论

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