(args []super.Value)
| 164 | } |
| 165 | |
| 166 | func (j *Join) Call(args []super.Value) super.Value { |
| 167 | args = underAll(args) |
| 168 | for _, val := range args { |
| 169 | if val.IsNull() { |
| 170 | return super.Null |
| 171 | } |
| 172 | } |
| 173 | splitsVal := args[0] |
| 174 | typ, ok := super.TypeUnder(splitsVal.Type()).(*super.TypeArray) |
| 175 | if !ok || typ.Type.ID() != super.IDString { |
| 176 | return j.sctx.WrapError("join: array of string arg required", splitsVal) |
| 177 | } |
| 178 | var separator string |
| 179 | if len(args) == 2 { |
| 180 | sepVal := args[1] |
| 181 | if !sepVal.IsString() { |
| 182 | return j.sctx.WrapError("join: separator must be string", sepVal) |
| 183 | } |
| 184 | separator = super.DecodeString(sepVal.Bytes()) |
| 185 | } |
| 186 | var b strings.Builder |
| 187 | var sep string |
| 188 | it := splitsVal.Bytes().Iter() |
| 189 | for !it.Done() { |
| 190 | b.WriteString(sep) |
| 191 | b.WriteString(super.DecodeString(it.Next())) |
| 192 | sep = separator |
| 193 | } |
| 194 | return super.NewString(b.String()) |
| 195 | } |
| 196 | |
| 197 | type Levenshtein struct { |
| 198 | sctx *super.Context |
nothing calls this directly
no test coverage detected