The brackets are a documentation convention for optional so the brackets in
start_with?([prefixes]+) → true or false
are just saying that you can call start_with?
with zero or more prefixes
. This is a common convention in documentation, you'll see it the jQuery documentation, Backbone documentation, MDN JavaScript documentation, and pretty much any other software documentation.
If you have an array of prefixes that you want to use with start_with?
, then you can splat the array to unarrayify it thusly:
a = %w[heaven hell]
'hello'.start_with?(*a) # true
a = %w[where is]
'pancakes house?'.start_with?(*a) # false