x.map!{|el| el == "foo" ? "bar" : el}
(replace {"foo" "bar"} x)
std::replace(x.begin(), x.end(), "foo", "bar");
int i;
while ((i = x.IndexOf("foo")) != -1)
x[i] = "bar";
for (var i = 0; i < x.length; i++) {
if (x[i] == 'foo') x[i] = 'bar';
}
x = x.map((e) => e == 'foo' ? 'bar' : e).toList();
[case Elem of "foo" -> "bar"; _ -> Elem end || Elem <- X].
where (x == "foo")
x = "bar"
endwhere
func replaceAll[T comparable](s []T, old, new T) {
for i, v := range s {
if v == old {
s[i] = new
}
}
}
replaceAll(x, "foo", "bar")
for i, v := range x {
if v == "foo" {
x[i] = "bar"
}
}
replaced = map (\e -> if e == "foo" then "bar" else e) x
x = x.map(e => e === 'foo' ? 'bar' : e);
x = x.stream()
.map(s -> s.equals("foo") ? "bar" : s)
.toList();
x.replaceAll(e -> e.equals("foo") ? "bar" : e);
ListIterator<String> i = x.listIterator();
while (i.hasNext())
if (i.next().equals("foo")) i.set("bar");
for i := 0 to x.count - 1 do
if x[i] = 'foo' then
x[i] := 'bar';
map { s/^foo$/bar/g } @x;
for i, v in enumerate(x):
if v == "foo":
x[i] = "bar"
x = ["bar" if v=="foo" else v for v in x]
for i, v in enumerate(x):
if v == 'foo': x[i] = 'bar'
for v in &mut x {
if *v == "foo" {
*v = "bar";
}
}