[MacRuby-devel] [MacRuby] #403: rescue block executed if exception raised in previous iteration
#403: rescue block executed if exception raised in previous iteration
---+
Reporter: pwil...@… | Owner: lsansone...@…
Type: defect | Status: new
Priority: major | Milestone: MacRuby 0.5
Component: MacRuby|Keywords:
---+
If a begin/rescue block is inside an iterator and the block raises an
exception on the first iteration but calls return on the second iteration,
the return is ignored and the rescue block ran a second time. Here is an
example:
{{{
def main
[1,2].each do |iter|
puts "Starting iteration #{iter}"
begin
if iter == 1
raise StandardError
end
puts " Successful iteration #{iter}"
return true
rescue StandardError
puts " Failed iteration #{iter}"
next
end
end
return false
end
puts main
}}}
In Ruby 1.8.7, the main method returns true, but in the Oct 24 nightly
build of MacRuby, it returns false with this output:
{{{
Starting iteration 1
Failed iteration 1
Starting iteration 2
Successful iteration 2
Failed iteration 2
false
}}}
Note that on the second iteration, both the Successful and Failed log
messages get printed.
--
Ticket URL:
MacRuby
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] Implementing Undo In RaiseMan / MacRuby
I'm trying to implement the RaiseMan example from Aaron Hillegass's
book in MacRuby. All has gone pretty well until I reached undo. The
idea is to handle the insertObject message each time a Person is
inserted and manipulate the undo stack.
def insertObject(p, inEmployeesAtIndex:index)
NSLog("adding #{p} to #{employees}") # <= Not called, huh?
undo = @undoManager
undo.prepareWithInvocationTarget(self,
removeObjectFromEmployeesAtIndex:index)
if !undo.isUndoing
undo.setActionName("Insert Person")
end
employees.insertObject(p, atIndex:index)
end
The Objective-C signature for this is:
- (void)insertObject:(Person *)p inEmployeesAtIndex:(int)index
Works in Objective-C but in my Ruby, the method is not recognized as a
handler to be invoked when a Person object is to be inserted in the
employees array. I should note that I created the employees array
using Ruby syntax:
@employees ||= []
Changing this to:
@employees ||= NSMutableArray.alloc.init
makes no difference in this scenario.
Any hints with respect to what I'm missing here?
Thanks,
Steve
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] Drawing in Custom Views
Hey, just saw the previous question regarding an example from the Cocoa book. I'm currently trying play with custom views and paths. Right now I'm trying the Example from page 240 »Drawing with NSBezierPath« but I can't get the path to draw. I uploaded the xcode project onto http://smyck.org/drawing.zip The Controller is quite simple http://pastie.textmate.org/private/kafqjbqoml48otms0ddcqq Something is not right but I don't know what - maybe one of you more experienced cocoa coders can help me out. Kind regards, John ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Drawing in Custom Views
Ah never mind. If I put the path drawing code directly into the drawRect method it all works fine. The whole thing now looks like this: http://pastie.textmate.org/private/rczadjlgyv63txzv6raea ~ John On 25.10.2009, at 20:36, John-Paul Bader wrote: Hey, just saw the previous question regarding an example from the Cocoa book. I'm currently trying play with custom views and paths. Right now I'm trying the Example from page 240 »Drawing with NSBezierPath« but I can't get the path to draw. I uploaded the xcode project onto http://smyck.org/drawing.zip The Controller is quite simple http://pastie.textmate.org/private/kafqjbqoml48otms0ddcqq Something is not right but I don't know what - maybe one of you more experienced cocoa coders can help me out. Kind regards, John ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] new macruby tips: dialog window
I'm back from vacation and wrote a very simple tutorial: MacRuby tips: create a Cocoa file/folder browser in a few lines of code: http://bit.ly/1VuxBZ It looks like it's time for me to move my tutorials http://merbist.com/category/macruby/ to MacRuby's recipes. Anyone feels like contributing more examples/tutorials? - Matt ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] new macruby tips: dialog window
On Oct 25, 2009, at 5:00 PM, Matt Aimonetti wrote: I'm back from vacation and wrote a very simple tutorial: MacRuby tips: create a Cocoa file/folder browser in a few lines of code: http://bit.ly/1VuxBZ It looks like it's time for me to move my tutorials http://merbist.com/category/macruby/ to MacRuby's recipes. Anyone feels like contributing more examples/tutorials? - Matt ___ This might be a bit OT, but I poked around github looking for a MacRuby version of Aaron Hillegass's RaiseMan and found DrNic's effort. I've gotten a bit further, so I put it out there as: http://github.com/sxross/raiseman-rb I'm a Cocoa n00b, so I decided that instead of the meatier "real" projects that I wanted to do, I would work doggedly through Aaron's examples in Objective-C and then do MacRuby ports as I went along. I've hit a few snags, but my goal is to have a completely functional RaiseMan in MacRuby by the end of the exercise, and perhaps to inject some idiomatic Rubyisms into the end product. -- Steve___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] new macruby tips: dialog window
Hey Steve, Check John's repo: http://idisk.mac.com/johnmshea-Public?view=web he did a great job porting examples from the book and other examples. That might help you in your quest to Cocoa knowledge :) - Matt On Sun, Oct 25, 2009 at 7:10 PM, s.ross wrote: > On Oct 25, 2009, at 5:00 PM, Matt Aimonetti wrote: > > I'm back from vacation and wrote a very simple tutorial: > MacRuby tips: create a Cocoa file/folder browser in a few lines of code: > http://bit.ly/1VuxBZ > > It looks like it's time for me to move my tutorials > http://merbist.com/category/macruby/ to MacRuby's recipes. > > Anyone feels like contributing more examples/tutorials? > > - Matt > ___ > > > This might be a bit OT, but I poked around github looking for a MacRuby > version of Aaron Hillegass's RaiseMan and found DrNic's effort. I've gotten > a bit further, so I put it out there as: > > http://github.com/sxross/raiseman-rb > > I'm a Cocoa n00b, so I decided that instead of the meatier "real" projects > that I wanted to do, I would work doggedly through Aaron's examples in > Objective-C and then do MacRuby ports as I went along. I've hit a few snags, > but my goal is to have a completely functional RaiseMan in MacRuby by the > end of the exercise, and perhaps to inject some idiomatic Rubyisms into the > end product. > > -- Steve > > ___ > MacRuby-devel mailing list > [email protected] > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel > > ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Drawing in Custom Views
Hey John, You shouldn't need to put everything in drawRect:. In your original, you're stomping @path in your drawRect. :) --Mike On Oct 25, 2009, at 4:21 PM, John-Paul Bader wrote: Ah never mind. If I put the path drawing code directly into the drawRect method it all works fine. The whole thing now looks like this: http://pastie.textmate.org/private/rczadjlgyv63txzv6raea ~ John On 25.10.2009, at 20:36, John-Paul Bader wrote: Hey, just saw the previous question regarding an example from the Cocoa book. I'm currently trying play with custom views and paths. Right now I'm trying the Example from page 240 »Drawing with NSBezierPath« but I can't get the path to draw. I uploaded the xcode project onto http://smyck.org/drawing.zip The Controller is quite simple http://pastie.textmate.org/private/kafqjbqoml48otms0ddcqq Something is not right but I don't know what - maybe one of you more experienced cocoa coders can help me out. Kind regards, John ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
