From: Morton Goldberg Date: 2008-02-27T06:19:28+09:00 Subject: Re: Ruby/Tk On Feb 26, 2008, at 12:54 PM, Isaac Toothyxdip wrote: > Thank you this is exactly what i was wanting! Im going to try to > find a > good class tutorial so i can understand them a little more just the > only > thing i didnt understand to well was this > Morton Goldberg wrote: >> # Make Cmnd+Q work as expected on OS X. >> if RUBY_PLATFORM =~ /darwin/ >> root.bind('Command-q') { root.destroy } > > i under stand what it does and i under stand the root.bind(....)..... > but i just dont under stand the "=~ /darwin/" What is it telling the > computer to look for?. '=~' is the regular expression match operator. It's a way of asking: does the pre-defined Ruby constant RUBY_PLATFORM contain the string 'darwin'. When Ruby runs under OS X, the answer will be yes -- that is, 'RUBY_PLATFORM =~ /darwin/' evaluates to non-nil on a Macintosh running OS X, but not on one running Linux or Windows (and, yes, a Macintosh can run Linux or Windows). > Also if you can do this does this mean that i could make a program > that > lets say if you press F10 then it can turn a continues loop on and > off? > > Like if pressed it sends z over and over again and if you press it > again > it stops. Yes, you could do that. You can use the bind method to bind an action to any keyboard event. Further bind can be used to bind actions to other operating system events as well. Regards, Morton