From: Robert Klemme Date: 2010-04-06T02:05:05+09:00 Subject: Re: When {integer:0} <> 0 ??? On 04/05/2010 05:13 PM, Jesús Gabriel y Galán wrote: > On Mon, Apr 5, 2010 at 5:10 PM, Richard Fairbanks wrote: >> Thank you, Jesús and Brian, that was what I needed! >> >> Please forgive me for my vast ignorance. I have learned so many >> different Mac scripting languages over the years and all of them "have >> left the choir invisible and are pushing up daisies." Thus I had no >> choice but to learn AppleScript. ;-) >> >> I am THRILLED that Ruby looks like a keeper! and I apologize again for >> my extreme Ruby "noobieness." > > No need to apologize. As I read sometimes in this list (I think it's > Robert Klemme who usually says this) we all started as newbies at some > point :-) I couldn't agree more. ;-) Just one additional bit of information: the syntax with the colon is not supported any more in 1.9.1: robert@fussel:~$ ruby -vc x.rb ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux] x.rb:7: warning: unused literal ignored Syntax OK robert@fussel:~$ ruby19 -vc x.rb ruby 1.9.1p376 (2009-12-07 revision 26041) [i686-linux] x.rb:7: syntax error, unexpected ':', expecting keyword_then or ';' or '\n' if p(Y.z): 0 # I assume this is the culprit! ^ x.rb:7: warning: unused literal ignored x.rb:9: syntax error, unexpected keyword_end, expecting $end robert@fussel:~$ cat -n x.rb 1 require "appscript"; include Appscript 2 require 'osax'; include OSAX 3 4 module Y; def self.z; 0; end; end 5 osax.say(Y.z) #=> "zero" 6 7 if p(Y.z): 0 # I assume this is the culprit! 8 osax.say(Y.z) #=> silence 9 end 10 11 osax.set_the_clipboard_to(Y.z) #=> {integer:0} 12 robert@fussel:~$ Brian is absolutely right: the colon in this place is used so rarely that I even had forgotten about it. While we're at it, let's check another usage: robert@fussel:~$ ruby -vce 'case x; when 1: puts true else puts false end' ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux] Syntax OK robert@fussel:~$ ruby19 -vce 'case x; when 1: puts true else puts false end' ruby 1.9.1p376 (2009-12-07 revision 26041) [i686-linux] -e:1: syntax error, unexpected ':', expecting keyword_then or ',' or ';' or '\n' case x; when 1: puts true else puts false end ^ robert@fussel:~$ Aha, colon disappeared with "when" as well. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/