| Extracted from Pike v7.8 release 866 at 2018-07-18.

[Top]

# Method `*()

Method `*

  `mixed `*(mixed arg1)`
  `mixed `*(object arg1, mixed arg2, mixed ... extras)`
  `mixed `*(mixed arg1, object arg2)`
  `array `*(array arg1, int arg2)`
  `array `*(array arg1, float arg2)`
  `string `*(string arg1, int arg2)`
  `string `*(string arg1, float arg2)`
  `string `*(array(string) arg1, string arg2)`
  `array `*(array(array) arg1, array arg2)`
  `float `*(float arg1, int|float arg2)`
  `float `*(int arg1, float arg2)`
  `int `*(int arg1, int arg2)`
  `mixed `*(mixed arg1, mixed arg2, mixed ... extras)`

Description

  Multiplication/repetition/implosion.

  Every expression with the `*` operator becomes a call to this function, i.e. `a*b` is the same as `predef::`*(a,b)`. Longer `*` expressions are normally optimized to one call, so e.g. `a*b*c` becomes `predef::`*(a,b,c)`.

Returns

  If there's a single argument, that argument will be returned.

  If the first argument is an object that implements lfun::`*() , that function will be called with the rest of the arguments.

  If there are more than two arguments, the result will be ``*(`*(<font face='courier'>arg1` , <font face='courier'>arg2 ), @<font face='courier'>extras ).

  If arg2 is an object that implements lfun::``*() , that function will be called with arg1 as the single argument.

  Otherwise the result will be as follows:

  `arg1` can have any of the following types:

  `array`

  `arg2` can have any of the following types:

  `int|float` | The result will be arg1 concatenated arg2 times.
  `string|array` | The result will be the elements of arg1 concatenated with arg2 interspersed.

  `string` | The result will be arg1 concatenated arg2 times.
  `int|float` | The result will be `<font face='courier'>arg1` * <font face='courier'>arg2 , and will be a float if either arg1 or arg2 is a float.

Note

  In Pike 7.0 and earlier the multiplication order was unspecified.

See also

  `+() , `-() , `/() , lfun::`*() , lfun::``*()