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!!"

This method returns an undefined value.

Parameters:

  • str (String)

    文字列

  • func (block)

    関数型(引数:文字列, 戻り値:なし)



105
106
107
108
# File 'lib/hellojava.rb', line 105

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"

This method returns an undefined value.

Parameters:

  • func (block)

    関数型(引数:なし, 戻り値:文字列)



119
120
121
122
# File 'lib/hellojava.rb', line 119

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

This method returns an undefined value.

Parameters:

  • vals (Array)

    double型の配列(duble[])

  • func (block)

    関数型(引数:double[], 戻り値:double)



135
136
137
138
# File 'lib/hellojava.rb', line 135

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