04 - calling java libraries with jruby.rb
来自「O Reilly Ruby Cookbook source code」· RB 代码 · 共 29 行
RB
29 行
#!/usr/bin/env jruby# random.jrbrequire 'java'include_class 'java.util.Random'r = Random.new(123)puts "Some random number #{r.nextInt % 10}"r.seed = 456puts "Another random number #{r.nextInt % 10}"#---$ jruby random.jrbSome random number 9Another random number 0#---include_class('java.lang.String') { |package,name| "J" + name }#---class Foo { public void bar(int arg) {...} public void bar(long arg) {...}}#--- Foo.new.bar(5)#---setSeed(value);#---seed = value#---
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?