"String interpolation"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-== 참고 자료 == +==참고==))
잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(다른 사용자 한 명의 중간 판 3개는 보이지 않습니다)
3번째 줄: 3번째 줄:
;variable interpolation
;variable interpolation
;string interpolation
;string interpolation
;문자열 인터폴레이션, 스트링 인터폴레이션
*문자열 중간에 있는 변수를 값으로 바꿈
*문자열 중간에 있는 변수를 값으로 바꿈


==Bash==
==Bash==
[[category: Bash]]
[[category: Bash]]
<source lang='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
</source>
</syntaxhighlight>


==Perl==
==Perl==
[[category: Perl]]
[[category: Perl]]
<source lang='Perl'>
<syntaxhighlight lang='Perl'>
my $apples = 4;
my $apples = 4;
print "I have $apples apples\n";
print "I have $apples apples\n";
</source>
</syntaxhighlight>


==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
<source lang='PHP'>
<syntaxhighlight lang='PHP'>
$name = 'Snoopy';
$name = 'Snoopy';
echo "His name is $name";
echo "His name is $name";
// His name is Snoopy
// His name is Snoopy
</source>
</syntaxhighlight>


==Python==
==Python==
[[category: Python]]
[[category: Python]]
<source lang='Python'>
<syntaxhighlight lang='Python'>
apples = 4
apples = 4
print "I have %d apples" % apples
print "I have %d apples" % apples
38번째 줄: 39번째 줄:
# I have 4 apples
# I have 4 apples
# I have 4 apples
# I have 4 apples
</source>
</syntaxhighlight>


==Ruby==
==Ruby==
[[category: Ruby]]
[[category: Ruby]]
<source lang='Ruby'>
<syntaxhighlight lang='Ruby'>
apples = 4
apples = 4
puts "I have #{apples} apples"
puts "I have #{apples} apples"
# I have 4 apples
# I have 4 apples
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
54번째 줄: 55번째 줄:
*[[concatenate]]
*[[concatenate]]
*[[변수 삽입]]
*[[변수 삽입]]
*[[템플릿 엔진]]


==참고==
==참고==
*http://en.wikipedia.org/wiki/Variable_interpolation
*http://en.wikipedia.org/wiki/Variable_interpolation
*http://en.wikipedia.org/wiki/String_interpolation
*http://en.wikipedia.org/wiki/String_interpolation

2020년 11월 2일 (월) 02:31 기준 최신판

1 개요[ | ]

variable interpolation
string interpolation
문자열 인터폴레이션, 스트링 인터폴레이션
  • 문자열 중간에 있는 변수를 값으로 바꿈

2 Bash[ | ]

name=Snoopy
echo "His name is $name"
# His name is Snoopy

3 Perl[ | ]

my $apples = 4;
print "I have $apples apples\n";

4 PHP[ | ]

$name = 'Snoopy';
echo "His name is $name";
// His name is Snoopy

5 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

6 Ruby[ | ]

apples = 4
puts "I have #{apples} apples"
# I have 4 apples

7 같이 보기[ | ]

8 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}