Created
February 10, 2013 23:48
-
-
Save tissak/4751575 to your computer and use it in GitHub Desktop.
Demonstrating working and non working module change code in rubymotion. Code was verified on rake console.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(main)> z.q | |
Assertion failed: (b != NULL), function rb_vm_block_method_imp, file vm.cpp, line 3000. | |
*** simulator session ended with error: Error Domain=DTiPhoneSimulatorErrorDomain Code=1 "The simulated application quit." UserInfo=0x100461550 {NSLocalizedDescription=The simulated application quit., DTiPhoneSimulatorUnderlyingErrorCodeKey=-1} | |
rake aborted! | |
Command failed with status (1): [DYLD_FRAMEWORK_PATH="/Applications/Xcode.a...] | |
/Library/RubyMotion/lib/motion/project.rb:101:in `block in <top (required)>' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mod = Module.new do | |
public_class_method :define_method | |
def q | |
'q' | |
end | |
end | |
mod.define_method :r do | |
'r' | |
end | |
Kernel.const_set 'X', mod | |
class Y | |
include X | |
end | |
z = Y.new | |
z.q | |
#> q | |
z.r | |
# Crash | |
# Assertion failed: (b != NULL), function rb_vm_block_method_imp, file vm.cpp, line 3000. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Module B | |
def a | |
'a' | |
end | |
end | |
Class A | |
include B | |
end | |
a = A.new | |
a.a | |
#> a | |
Module B | |
def c | |
'c' | |
end | |
end | |
a.c | |
#> c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment