mirror of
https://github.com/vlang/v.git
synced 2025-09-14 06:52:36 +03:00
examples: show how to create and pass a V string to a V function, and then get back a V string in Python
This commit is contained in:
parent
193a99d1e7
commit
cc92dbc8a5
2 changed files with 21 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
module test
|
||||
|
||||
// Note: compile this with `v -d no_backtrace -shared test.v`
|
||||
import math
|
||||
|
||||
@[export: 'square']
|
||||
|
@ -11,3 +12,9 @@ fn square(i int) int {
|
|||
fn sqrt_of_sum_of_squares(x f64, y f64) f64 {
|
||||
return math.sqrt(x * x + y * y)
|
||||
}
|
||||
|
||||
// you do not have to use the same name in the export attribute
|
||||
@[export: 'process_v_string']
|
||||
fn work(s string) string {
|
||||
return 'v ${s} v'
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue