Class: HelloJavaLib::FuncTypes

Inherits:
Object
  • Object
show all
Defined in:
lib/hellojava.rb

Overview

引数に関数型の場合

Class Method Summary collapse

Class Method Details

.func_type1(str, &func) ⇒ void

Examples:

HelloJavaLib::FuncTypes.func_type1("Hello") {|s|
  p s + "!!"
  next
}
=>
  funcType1 in
  "Hello!!"


82
83
84
85
# File 'lib/hellojava.rb', line 82

def func_type1(str, &func)
    JavaCallTest2.funcType1(str, func)
    return
end

.func_type2(&func) ⇒ void

Examples:

HelloJavaLib::FuncTypes.func_type2() {
  next "Hello"
}
=>
  funcType2 in
  "Hello"


96
97
98
99
# File 'lib/hellojava.rb', line 96

def func_type2(&func)
    p JavaCallTest2.funcType2(func)
    return
end

.func_type3(vals, &func) ⇒ void

Examples:

vals = [11, 22, 33, 44]
HelloJavaLib::FuncTypes.func_type3(vals) {|xi|
  next xi.sum(0.0) / xi.length
}
=>
  funcType3 in
  27.5


112
113
114
115
# File 'lib/hellojava.rb', line 112

def func_type3(vals, &func)
    p JavaCallTest2.funcType3(vals.to_java(Java::double), func)
    return
end