"함수 정의"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(사용자 2명의 중간 판 10개는 보이지 않습니다)
5번째 줄: 5번째 줄:
==Bash==
==Bash==
[[category: bash]]
[[category: bash]]
<source lang='bash'>
{{참고|Bash 함수 정의}}
<syntaxhighlight lang='bash'>
greet() {
greet() {
echo 'hello'
echo 'hello'
11번째 줄: 12번째 줄:
greet
greet
# hello
# hello
</source>
</syntaxhighlight>
<source lang='bash'>
function greet() {
echo 'hello'
}
greet
# hello
</source>


==JavaScript==
==JavaScript==
[[category: JavaScript]]
[[category: JavaScript]]
<source lang='JavaScript'>
<syntaxhighlight lang='JavaScript'>
function greet() {
function greet() {
console.log("hello");
console.log("hello");
28번째 줄: 22번째 줄:
greet();
greet();
// hello
// hello
</source>
</syntaxhighlight>
<source lang='JavaScript'>
<syntaxhighlight lang='JavaScript'>
var greet = function() {
var greet = function() {
console.log("hello");
console.log("hello");
35번째 줄: 29번째 줄:
greet();
greet();
// hello
// hello
</source>
</syntaxhighlight>


==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
<source lang='PHP'>
<syntaxhighlight lang='PHP'>
function greet() {
function greet() {
print("hello");
print("hello");
45번째 줄: 39번째 줄:
greet();
greet();
# hello
# hello
</source>
</syntaxhighlight>


==Python==
==Python==
[[category: Python]]
[[category: Python]]
<source lang='Python'>
{{참고|파이썬 함수정의 def}}
<syntaxhighlight lang='Python'>
def greet():
def greet():
print('hello')
print('hello')
55번째 줄: 50번째 줄:
greet()
greet()
# hello
# hello
</source>
</syntaxhighlight>
<source lang='Python'>
<syntaxhighlight lang='Python'>
def show_ answer():
def show_ answer():
print(42)
print(42)
62번째 줄: 57번째 줄:
show_answer()
show_answer()
# 42
# 42
</source>
</syntaxhighlight>
 
==Perl==
[[분류:Perl]]
<syntaxhighlight lang='Perl'>
sub greet() {
print "hello\n";
}
 
greet();
</syntaxhighlight>
 
==R==
[[분류: R]]
<syntaxhighlight lang='r'>
greet <- function() {
  cat("hello")
}
 
greet()
## hello
</syntaxhighlight>


==Ruby==
==Ruby==
[[category: Ruby]]
[[category: Ruby]]
<source lang='Ruby'>
<syntaxhighlight lang='Ruby'>
def greet
def greet
   puts "hello"  
   puts "hello"  
73번째 줄: 89번째 줄:
greet
greet
# hello
# hello
</source>
</syntaxhighlight>
 
==Windows Batch==
<syntaxhighlight lang='batch'>
@echo off
call :greet hello
goto :eof
 
:greet <resultVar>
echo %~1
goto :eof
</syntaxhighlight>


==같이 보기==
==같이 보기==

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

function
def

1 Bash[ | ]

greet() {
	echo 'hello'
}
greet
# hello

2 JavaScript[ | ]

function greet() {
	console.log("hello");
}
greet();
// hello
var greet = function() {
	console.log("hello");
}
greet();
// hello

3 PHP[ | ]

function greet() {
	print("hello");
}
greet();
# hello

4 Python[ | ]

def greet():
	print('hello')

greet()
# hello
def show_ answer():
	print(42)

show_answer()
# 42

5 Perl[ | ]

sub greet() {
	print "hello\n";
}

greet();

6 R[ | ]

greet <- function() {
  cat("hello")
}

greet()
## hello

7 Ruby[ | ]

def greet
   puts "hello" 
end

greet
# hello

8 Windows Batch[ | ]

@echo off
call :greet hello
goto :eof

:greet <resultVar>
echo %~1
goto :eof

9 같이 보기[ | ]

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