Skip to content

Commit 6ec3d20

Browse files
committed
Add note to docs, and example that takes a parameter.
1 parent cfd13ef commit 6ec3d20

File tree

1 file changed

+13
-2
lines changed
  • app/server/ruby/lib/sonicpi/lang

1 file changed

+13
-2
lines changed

app/server/ruby/lib/sonicpi/lang/core.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2770,7 +2770,9 @@ def define(name, &block)
27702770
accepts_block: true,
27712771
requires_block: true,
27722772
intro_fn: true,
2773-
doc: "Allows you to group a bunch of code and give it your own name for future re-use. Functions are very useful for structuring your code. They are also the gateway into live coding as you may redefine a function whilst a thread is calling it, and the next time the thread calls your function, it will use the latest definition.",
2773+
doc: "Allows you to group a bunch of code and give it your own name for future re-use. Functions are very useful for structuring your code. They are also the gateway into live coding as you may redefine a function whilst a thread is calling it, and the next time the thread calls your function, it will use the latest definition.
2774+
2775+
Note, it is not recommended to start a function name with a capital letter if it takes no parameters.",
27742776
examples: ["
27752777
# Define a new function called foo
27762778
define :foo do
@@ -2785,7 +2787,16 @@ def define(name, &block)
27852787
# For example, in a block:
27862788
3.times do
27872789
foo
2788-
end",]
2790+
end",
2791+
2792+
"
2793+
# Define a new function called play2, taking one parameter
2794+
define :play2 do |x|
2795+
play x, release: 2
2796+
end
2797+
2798+
# Call play2, passing in a value for the parameter
2799+
play2 42"]
27892800

27902801

27912802

0 commit comments

Comments
 (0)