(새 문서: category: String ;variable interpolation ==Bash== category: Bash <source lang='bash'> name=Snoopy echo "His name is $name" # His name is Snoopy </source> ==PHP== category:...) |
Jmnote bot (토론 | 기여) 잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight)) |
||
| (사용자 2명의 중간 판 17개는 보이지 않습니다) | |||
| 1번째 줄: | 1번째 줄: | ||
[[category: String]] | [[category: String]] | ||
==개요== | |||
;variable interpolation | ;variable interpolation | ||
;string interpolation | |||
;문자열 인터폴레이션, 스트링 인터폴레이션 | |||
*문자열 중간에 있는 변수를 값으로 바꿈 | |||
==Bash== | ==Bash== | ||
[[category: Bash]] | [[category: Bash]] | ||
< | <syntaxhighlight lang='bash'> | ||
name=Snoopy | name=Snoopy | ||
echo "His name is $name" | echo "His name is $name" | ||
# His name is Snoopy | # His name is Snoopy | ||
</ | </syntaxhighlight> | ||
==Perl== | |||
[[category: Perl]] | |||
<syntaxhighlight lang='Perl'> | |||
my $apples = 4; | |||
print "I have $apples apples\n"; | |||
</syntaxhighlight> | |||
==PHP== | ==PHP== | ||
[[category: PHP]] | [[category: PHP]] | ||
< | <syntaxhighlight lang='PHP'> | ||
</ | $name = 'Snoopy'; | ||
echo "His name is $name"; | |||
// His name is Snoopy | |||
</syntaxhighlight> | |||
==Python== | |||
[[category: Python]] | |||
<syntaxhighlight lang='Python'> | |||
apples = 4 | |||
print "I have %d apples" % apples | |||
print "I have {} apples".format(apples) | |||
print "I have {a} apples".format(a=apples) | |||
# I have 4 apples | |||
# I have 4 apples | |||
# I have 4 apples | |||
</syntaxhighlight> | |||
==Ruby== | ==Ruby== | ||
[[category: Ruby]] | [[category: Ruby]] | ||
< | <syntaxhighlight lang='Ruby'> | ||
</ | apples = 4 | ||
puts "I have #{apples} apples" | |||
# I have 4 apples | |||
</syntaxhighlight> | |||
==같이 보기== | ==같이 보기== | ||
*[[print]] | *[[print]] | ||
*[[puts]] | |||
*[[string literal]] | |||
*[[concatenate]] | |||
*[[변수 삽입]] | |||
*[[템플릿 엔진]] | |||
==참고== | |||
*http://en.wikipedia.org/wiki/Variable_interpolation | |||
*http://en.wikipedia.org/wiki/String_interpolation | |||
2020년 11월 2일 (월) 02:31 기준 최신판
1 개요[ | ]
- variable interpolation
- string interpolation
- 문자열 인터폴레이션, 스트링 인터폴레이션
- 문자열 중간에 있는 변수를 값으로 바꿈
2 Bash[ | ]
Bash
Copy
name=Snoopy
echo "His name is $name"
# His name is Snoopy
3 Perl[ | ]
Perl
Copy
my $apples = 4;
print "I have $apples apples\n";
4 PHP[ | ]
PHP
Copy
$name = 'Snoopy';
echo "His name is $name";
// His name is Snoopy
5 Python[ | ]
Python
Copy
apples = 4
print "I have %d apples" % apples
print "I have {} apples".format(apples)
print "I have {a} apples".format(a=apples)
# I have 4 apples
# I have 4 apples
# I have 4 apples
6 Ruby[ | ]
Ruby
Copy
apples = 4
puts "I have #{apples} apples"
# I have 4 apples