Search
 
SCRIPT & CODE EXAMPLE
 

RUST

Repeat the given string exactly n times

# Repeat the given string exactly n times
def repeat_str (n, s)
  s*n
end
Comment

Repeat the given string exactly n times

// Repeat the given string exactly n times
public class Solution {
    public static String repeatStr(final int repeat, final String string) {
        String repeatedString = "";
        for (int i = 0; i < repeat; i++) {
          repeatedString += string;
        }
        return repeatedString;
    }
}
import java.util.Collections;
public class Solution {
    public static String repeatStr(final int repeat, final String string) {
        return repeat < 0 ? "" : String.join("", Collections.nCopies(repeat, string));
    }
}
Comment

Repeat the given string exactly n times

// Repeat the given string exactly n times
import java.util.Collections
object StringRepeat {
  def repeatStr(times: Int, str: String): String = {
    str * times
  }
}
Comment

Repeat the given string exactly n times

// Repeat the given string exactly n times
fn repeat_str(src: &str, count: usize) -> String {
  vec![src; count].join("")
}
Comment

PREVIOUS NEXT
Code Example
Rust :: armanriazi•rust•string 
Rust :: rust•armanriazi•type•wraper•mutable 
Rust :: get function name rust 
Rust :: Find the next smaller positive integer containing the same digits 
Rust :: rust convert floating point number, to a string, with decimal digits. 
Rust :: Read a floating point number from stdin 
Rust :: armanriazi•rust•reference•dangle 
Rust :: armanriazi•rust•error•[E0614]: cannot be dereferenced 
Rust :: overwritting print on same line rust 
Rust :: rust•armanriazi•cast•try_into•unwrap 
Rust :: rust get items in a list 
Rust :: armanriazi•substrate•call•dispatchable•func#ensure_signed#frame_system 
Rust :: armanriazi•rust•refactor•flowcontrol•match•unwrap_or_else 
Rust :: armanriazi•rust•trait•where 
Lua :: luau make rainbow part 
Lua :: roblox lua on player chatted 
Lua :: roblox difference between __index and __newindex 
Lua :: gfjhhkn roblox 
Lua :: roblox studio part color randomiser 
Lua :: lua what is _ENV 
Lua :: replace part of string lua 
Lua :: roblox camera manipulation 
Lua :: lua string replace 
Lua :: for loop in robox 
Lua :: 1.2 / 1.6 
Lua :: how do i use the love errors module lua assist 
Matlab :: matlab for loop matrix 
Matlab :: matlab make last value the first one etc 
Basic :: git token 
Basic :: VBA Initialise/Initialize String/Number Array (not variant) 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =