MCPcopy Create free account
hub / github.com/bazelbuild/bazel / join

Method join

src/main/java/net/starlark/java/eval/StringModule.java:140–168  ·  view source on GitHub ↗
(String self, StarlarkIterable<?> elements, StarlarkThread thread)

Source from the content-addressed store, hash-verified

138 }
139
140 @StarlarkMethod(
141 name = "join",
142 doc =
143 "Returns a string in which the string elements of the argument have been "
144 + "joined by this string as a separator. Example:<br>"
145 + "<pre class=\"language-python\">\"|\".join([\"a\", \"b\", \"c\"]) == \"a|b|c\""
146 + "</pre>",
147 parameters = {
148 @Param(name = "self"),
149 @Param(
150 name = "elements",
151 allowedTypes = {@ParamType(type = StarlarkIterable.class, generic1 = String.class)},
152 doc = "The objects to join.")
153 },
154 useStarlarkThread = true)
155 public String join(String self, StarlarkIterable<?> elements, StarlarkThread thread)
156 throws EvalException {
157 Iterable<?> items = Starlark.toIterable(elements);
158 int i = 0;
159 for (Object item : items) {
160 if (!(item instanceof String)) {
161 throw Starlark.errorf(
162 "expected string for sequence element %d, got '%s' of type %s",
163 i, Starlark.str(item, thread.getSemantics()), Starlark.type(item));
164 }
165 i++;
166 }
167 return Joiner.on(self).join(items);
168 }
169
170 @StarlarkMethod(
171 name = "lower",

Callers 15

mainFunction · 0.45
_replace_dirnameFunction · 0.45
mainFunction · 0.45
assertHasContentsMethod · 0.45
newShutdownHookMethod · 0.45
addResidueFromResultMethod · 0.45
addOptionInstanceMethod · 0.45
getCompletionMethod · 0.45
handleNewParsedOptionMethod · 0.45
fromLinesMethod · 0.45
getTextMethod · 0.45
toStringMethod · 0.45

Calls 5

toIterableMethod · 0.95
errorfMethod · 0.95
strMethod · 0.95
typeMethod · 0.95
getSemanticsMethod · 0.80

Tested by 3

assertHasContentsMethod · 0.36
newShutdownHookMethod · 0.36
read_data_fileFunction · 0.36