这是Bar#do_things:
class Bar
def do_things
Foo.some_method(x) do |x|
y = x.do_something
return y_is_bad if y.bad? # how do i tell it to stop and return do_things?
y.do_something_else
end
keep_doing_more_things
end
end
Run Code Online (Sandbox Code Playgroud)
这是Foo#some_method:
class Foo
def self.some_method(targets, &block)
targets.each do |target|
begin
r = yield(target)
rescue
failed << target
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
我想过使用raise,但我试图让它变得通用,所以我不想把任何具体的东西放进去Foo.
得到一个新的mac,需要准备开发.我听说macports很棒,我应该用吗?它比手动下载和编译更容易吗?有人使用它有什么问题吗?
它适用于典型的ruby web开发.
谢谢