Yep, Chad Fowler explained to me that it's the difference between precedence
and binding with do/end vs {}
- Matt
On Sun, Jan 9, 2011 at 5:57 PM, Vincent Isambart wrote:
> > You are right, still a gotcha tho:
> >
> > Ruby 1.9.2:
> >
> > def foo(a, b={})
> > b[:handler].call if b.has_key?(
> You are right, still a gotcha tho:
>
> Ruby 1.9.2:
>
> def foo(a, b={})
> b[:handler].call if b.has_key?(:handler)
> end
> foo :bar, handler: Proc.new do
> puts 42
> end
>
> `new': tried to create Proc object without a block (ArgumentError)
Works if you add parentheses though :
Bob,
Could you share some of your code so maybe someone can help you?
Thanks,
- Matt
On Sun, Jan 9, 2011 at 3:46 PM, Robert Rice wrote:
> Hi Laurent:
>
> I switched from using REXML to NSXML. NSXML is trickier to use but
> considerably faster than REXML. The subclassing capability would make
Hi Laurent:
I switched from using REXML to NSXML. NSXML is trickier to use but considerably
faster than REXML. The subclassing capability would make my app even faster if
I can figure out how to use it. I doubt there is a problem except that the
NSXMLFidelityElement class is not mentioned in th
You are right, still a gotcha tho:
Ruby 1.9.2:
def foo(a, b={})
b[:handler].call if b.has_key?(:handler)
end
foo :bar, handler: Proc.new do
puts 42
end
`new': tried to create Proc object without a block (ArgumentError)
def foo(a, b={})
b[:handler].call if b.has_key?(:handler
This seems to be a Ruby syntax point, unrelated to MacRuby.
Laurent
On Jan 9, 2011, at 2:32 PM, Matt Aimonetti wrote:
> Laurent you are right, however I noticed a little gotcha:
>
> If you use the following code:
>
> panel.beginSheetModalForWindow window, completionHandler: Proc.new do
>
Laurent you are right, however I noticed a little gotcha:
If you use the following code:
panel.beginSheetModalForWindow window, completionHandler: Proc.new do
|result|
return if (result == NSCancelButton)
path = panel.filename
dest_path = applicationSupportFolder
guid
Hi Robert,
Could you reduce the problem to a simple script and paste the code here?
Thanks,
Laurent
On Jan 9, 2011, at 11:47 AM, Robert Rice wrote:
> I've been trying to subclass NSXMLElement in MacRuby without success. I have
> implemented NSXMLDocument.replacementClassForClass returning my c
Hi Rolando,
The syntax is simple, you simply pass a Proc project.
Here is an example:
framework 'Foundation'
a = [1, 2, 3, 4, 5]
a.enumerateObjectsUsingBlock(Proc.new { |obj, index, stop|
p obj
stop.assign(true) if index == 2
})
It
This hack isn't needed anymore as of 0.8.
Passing the Proc inline should just be fine.
Laurent
On Jan 9, 2011, at 12:22 PM, Matt Aimonetti wrote:
> I suspect this has to do with keeping a reference so it doesn't get GC'd.
> Just a hunch. Am I getting there?
>
> That's my guess too, if you pas
>
> I suspect this has to do with keeping a reference so it doesn't get GC'd.
> Just a hunch. Am I getting there?
>
That's my guess too, if you pass the lambda as a param, it might get GC'd
and when the panel is done, it won't have a reference to the handler.
- Matt
On Sun, Jan 9, 2011 at 11:46
I've been trying to subclass NSXMLElement in MacRuby without success. I have
implemented NSXMLDocument.replacementClassForClass returning my custom subclass
to replace NSXMLElement but the parser returns NSXMLFidelityElement instances
rather than my custom class instances.
Has anyone done this
So It seems to me the only change there is uninlining the lambda and assigning
it to a throwaway variable. That feels like busywork.
I suspect this has to do with keeping a reference so it doesn't get GC'd. Just
a hunch. Am I getting there?
Why is this needed?
On 2011-01-09, at 17:10 , Matt A
I realize I didn't really reply to your question, the following code should
work:
{{{
def loadSprite(sender)
handler = lambda do |code|
return if code == NSCancelButton
# do things with the panel's date otherwise
end
@panel.beginSheetModalForWindow(@window, completionHandler: h
Hi,
I tried out the nightly build and gem by itself seems to work fine for the
tasks I commonly use;
- uninstall a gem with and without native extensions
- install a gem with and without native extensions
- install a specific version of a gem
- update gems
Though,
Here is an example of how to use NSOpenPanel:
https://github.com/mattetti/pastis/blob/master/app/Pastis/filter_window_controller.rb#L145-160
def browse(sender)
dialog = NSOpenPanel.openPanel
# Disable the selection of files in the dialog.
dialog.canChooseFiles = false
# Enable
Hi all,
I've taken a look at the referred issue (#712), but I'm not sure of
the final implemented syntax. I'm trying to use a NSOpenPanel, so far
this is what I'm doing:
{{{
def loadSprite(sender)
@panel.beginSheetModalForWindow(@window, completionHandler:lambda { |code|
NSLog("code:
17 matches
Mail list logo