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
all_foos = [] | |
class Foo | |
def initialize(foos) | |
foos << self | |
end | |
end | |
p all_foos # => [] | |
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
C:\ironruby\bin>ir | |
IronRuby 1.0.0.0 on .NET 2.0.50727.1433 | |
Copyright (c) Microsoft Corporation. All rights reserved. | |
Note that local variables do not work today in the console. | |
As a workaround, use globals instead (eg $x = 42 instead of x = 42). | |
>>> ENV['GEM_PATH'] = 'C:\\Programmi\\Ruby\\lib\\ruby\\gems\\1.8\\' | |
=> "C:\\Programmi\\Ruby\\lib\\ruby\\gems\\1.8\\" | |
>>> require 'rubygems' |
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
-- A function in Lua similar to PHP's print_r, from http://luanet.net/lua/function/print_r | |
function print_r ( t ) | |
local print_r_cache={} | |
local function sub_print_r(t,indent) | |
if (print_r_cache[tostring(t)]) then | |
print(indent.."*"..tostring(t)) | |
else | |
print_r_cache[tostring(t)]=true | |
if (type(t)=="table") then |
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
handlers := Map clone | |
handlers atPut("reset", method( | |
"reset" | |
)) | |
handlers atPut("compile", method(fun_source, | |
Compiler messageForString(fun_source) doInContext(self) | |
)) | |
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
Nrk := Object clone do ( | |
forward := method("Method called: #{call message name}" interpolate println) | |
) | |
Nrk foo("bar") # prints "Method called: foo" |
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
# code taken from http://www.rubycentral.com/pickaxe/tut_threads.html#UF | |
require 'thread' | |
mutex = Mutex.new | |
cv = ConditionVariable.new | |
a = Thread.new { | |
mutex.synchronize { | |
puts "A: I have critical section, but will wait for cv" | |
cv.wait(mutex) |
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
Ruby 1.8.6 (expected behaviour) | |
irb(main):001:0> gets | |
hello | |
=> "hello\n" | |
irb(main):002:0> $_ | |
=> "hello\n" | |
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
Error 1 Friend access was granted to 'ClassInitGenerator, | |
PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9', | |
but the output assembly is named 'ClassInitGenerator, Version=1.0.0.0, Culture=neutral, | |
PublicKeyToken=null'. Try adding a reference to 'ClassInitGenerator, | |
PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9' | |
or changing the output assembly name to match. c:\Development\ironruby\Merlin\Main\bin\Debug | |
\IronRuby.dll ClassInitGenerator | |
Er |
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 'rexml/document' | |
require 'ftools' | |
include REXML | |
# ---------------------------------------------------------------------------------------- # | |
GIT_ROOT = 'C:/Development/ironruby' | |
SUPPORT_DIR = File.join(GIT_ROOT, 'Merlin/Main/Support') | |
# ---------------------------------------------------------------------------------------- # |
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 'hpricot' | |
xml =<<XML | |
<items> | |
<item number="1"> | |
<name>item #1</name> | |
</item> | |
<item number="2"> | |
<title>item #2</title> | |
</item> |