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
require "stitcher" | |
using Stitcher | |
class Super | |
stitcher_require [Fixnum] | |
def func a | |
p "Fixnum" | |
end | |
end |
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
require "stitcher" | |
using Stitcher | |
class Array | |
stitcher_require +[Fixnum, Fixnum] | |
def at *indices | |
at(indices.shift).at(*indices) | |
end | |
end |
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
class Object | |
def _ | |
self_ = self | |
Class.new(BasicObject) do | |
define_singleton_method(:method_missing) do |name, *args, &block| | |
return self_.__send__(name, *args, &block) unless block && block.parameters.size == 0 | |
self_.__send__(name, *args) do |*args| | |
Object.new.instance_eval do | |
define_singleton_method(:_) { args[0] } | |
args.size.times do |i| |
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 Hoge | |
def hoge_method | |
end | |
refine Class do | |
def class_ex | |
end | |
end |
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 ExImpl | |
def homu | |
p "homu" | |
end | |
end | |
module Ex | |
refine Module do | |
include ExImpl |
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 Homu | |
def homu | |
# Error: `homu': undefined local variable or method `mami' for X:Class (NameError) | |
mami | |
end | |
def mami | |
p :mami | |
end | |
end |
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
class X | |
extend Define | |
plus(a: Fixnum, b: Fixnum){ | |
a + b | |
} | |
plus(a: String, b: String){ | |
"#{a}:#{b}" | |
} |
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 M | |
def hoge | |
end | |
def foo | |
hoge | |
end | |
end |
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 ArrayEx | |
refine Array do | |
def === other | |
each_with_index do |it, index| | |
return false unless it === other[index] | |
end | |
true | |
end | |
end | |
end |
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
def call_one &block | |
result = nil | |
proc { |*args| result ||= instance_exec(*args, &block) } | |
end | |
twice = call_one { |a| a + a } | |
p twice.call "homu" | |
p twice.call "mami" |