[4387] MacRubyWebsite/trunk/content/documentation/rubycocoa-to-macruby.txt
Revision: 4387 http://trac.macosforge.org/projects/ruby/changeset/4387 Author: lsansonetti@apple.com Date: 2010-07-28 12:46:49 -0700 (Wed, 28 Jul 2010) Log Message: ----------- forgot to commit these small details Modified Paths: -------------- MacRubyWebsite/trunk/content/documentation/rubycocoa-to-macruby.txt Modified: MacRubyWebsite/trunk/content/documentation/rubycocoa-to-macruby.txt =================================================================== --- MacRubyWebsite/trunk/content/documentation/rubycocoa-to-macruby.txt 2010-07-28 19:40:27 UTC (rev 4386) +++ MacRubyWebsite/trunk/content/documentation/rubycocoa-to-macruby.txt 2010-07-28 19:46:49 UTC (rev 4387) @@ -114,8 +114,8 @@ <pre class="commands"> # MacRuby code def saveWorld(planet, fromVillain: badguy, withHero:superhero) - superhero.fight(badguy) - planet.thank(superhero) + superhero.fight(badguy) + planet.thank(superhero) end </pre> @@ -194,14 +194,14 @@ h3. Exception Handling -Though Ruby's @Exception@ class and Objective-C's @NSException@ class are not technically bridged classes, @begin...rescue@ blocks in MacRuby can catch both Ruby @Exceptions@ and Cocoa @NSExceptions@. Conversely, you can catch MacRuby @Exceptions@ with Objective-C's @try@@/@catch@. +Though Ruby's @Exception@ class and Objective-C's @NSException@ class are not technically bridged classes, @begin...rescue@ blocks in MacRuby can catch both Ruby @Exceptions@ and Cocoa @NSExceptions@. Conversely, you can catch MacRuby @Exceptions@ with Objective-C's @@try@/@@catch@. h3. Other Syntactic Extensions The MacRuby team has ported the syntactic extensions present in RubyCocoa for cases when Objective-C idioms differ with Ruby idioms, such as in the case of mutator methods and boolean accessor methods: <pre class="commands"> -layer.setPosition = [100, 100] # Objective-C style +layer.setPosition([100, 100]) # Objective-C style layer.position = [100, 100] # Ruby style; calls the same method the Objective-C one does layer.isHidden # Objective-C style layer.hidden? # Ruby allows the '?' character in method names
participants (1)
-
source_changes@macosforge.org