v / examples / call_v_from_ruby / test.v
14 lines · 11 sloc · 304 bytes · a80bc2331450fc28c900097f8afafe173f161d27
Raw
1// vtest build: present_ruby? // the example only makes sense to be compiled, when ruby is installed
2module test
3
4import math
5
6@[export: 'square']
7fn square(i int) int {
8 return i * i
9}
10
11@[export: 'sqrt_of_sum_of_squares']
12fn sqrt_of_sum_of_squares(x f64, y f64) f64 {
13 return math.sqrt(x * x + y * y)
14}
15