When developing in many languages for hobbies and work Since there are many mistakes in writing with a simple syntax, I will transcribe it.
Only the reference and code are described without any explanation.
Python
str.join (iterable) — Python 3.8.1 documentation
strings = ['fizz', 'buzz'];
merged_strings = ' '.join(strings)
print(merged_strings) # 'fizz buzz'
Ruby
Array # join (Ruby 2.7.0 Reference Manual)
strings = ['fizz', 'buzz']
merged_strings = strings.join(' ')
p merged_strings # "fizz buzz"
JavaScript
Array.prototype.join() - JavaScript | MDN
const strings = ['fizz', 'buzz'];
const mergedStrings = strings.join(' ');
console.log(mergedStrings); // 'fizz buzz'
$strings = ['fizz', 'buzz'];
$mergedStrings = implode(' ', $strings);
print($mergedStrings) // 'fizz buzz'
Python
7.1.1. Formatted String Literal — Python 3.8.1 Documentation
string_fizz, string_buzz = 'fizz', 'buzz'
string_fizz_buzz = f'{string_fizz} {string_buzz}'
print(string_fizz_buzz) # 'fizz buzz'
Ruby
Expression expansion (Ruby 2.7.0 reference manual)
string_fizz, string_buzz = 'fizz', 'buzz'
string_fizz_buzz = "#{string_fizz} #{string_buzz}"
p string_fizz_buzz # "fizz buzz"
JavaScript
Template string --JavaScript | MDN
const stringF = 'fizz'
const stringB = 'buzz'
const stringFizzBuzz = `${stringF} ${stringB}`
console.log(stringFizzBuzz) // 'fizz buzz'
PHP
PHP: Parsing Variables --Manual
[$stringF, $stringB] = ['fizz', 'buzz'];
$stringFizzBuzz = "${stringF} ${stringB}";
print($stringFizzBuzz); // 'fizz buzz'
Recommended Posts