함수 정의

function
def

1 Bash[ | ]

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

2 JavaScript[ | ]

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

3 PHP[ | ]

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

4 Python[ | ]

Python
Copy
def greet():
	print('hello')

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

show_answer()
# 42

5 Perl[ | ]

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

greet();

6 R[ | ]

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

greet()
## hello

7 Ruby[ | ]

Ruby
Copy
def greet
   puts "hello" 
end

greet
# hello

8 Windows Batch[ | ]

batch
Copy
@echo off
call :greet hello
goto :eof

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

9 같이 보기[ | ]