Skip to main content

repeat

Function repeat 

Source
pub fn repeat(args: &[Value]) -> Result<Value, RuntimeError>
Expand description

重复字符串

§功能

将字符串重复指定的次数。

§参数

  • string: String - 要重复的字符串
  • count: Number - 重复次数(必须是非负整数)

§返回值

String - 重复后的字符串

§错误

  • 重复次数为负数或非整数时抛出错误

§示例

Set STR "Ha"
Set LAUGH REPEAT(STR, 3)         // "HaHaHa"
Set DASH "-"
Set LINE REPEAT(DASH, 10)        // "----------"
Set SPACE " "
Set INDENT REPEAT(SPACE, 4)      // "    "