以下引用神思于2007-3-8 20:17:58的发言:
有个可以简化的东西`
if item.name.split(/,/)[2] == "0"
self.contents.font.color = text_color(0)
elsif item.name.split(/,/)[2] == "1"
self.contents.font.color = text_color(1)
elsif item.name.split(/,/)[2] == "2"
self.contents.font.color = text_color(2)
elsif item.name.split(/,/)[2] == "3"
self.contents.font.color = text_color(3)
elsif item.name.split(/,/)[2] == "4"
self.contents.font.color = text_color(4)
elsif item.name.split(/,/)[2] == "5"
self.contents.font.color = text_color(5)
elsif item.name.split(/,/)[2] == "6"
self.contents.font.color = text_color(6)
else
self.contents.font.color = text_color(7)
end
可以写长这样
if !item.name.split(/,/)[2].nil?
self.contents.font.color = text_color(item.name.split(/,/)[2].to_i)
else
self.contents.font.color = text_color(7)
end
还有一些比较诡异的地方``
有一些地方用到了alias 但是重定义后发现并没有调用回原来的方法``
[本贴由作者于 2007-3-8 20:20:02 最后编辑]
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |