"함수 println()"의 두 판 사이의 차이

12번째 줄: 12번째 줄:
[[category: Bash]]
[[category: Bash]]
{{참고|Bash echo}}
{{참고|Bash echo}}
<syntaxhighlight lang='Bash'>
<syntaxhighlight lang='Bash' run>
echo Hello!
echo hello
echo Hello!
echo world
# Hello!
# Hello!
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang='Bash'>
<syntaxhighlight lang='Bash' run>
hello='Hello!'
hello='Hello!'
echo $hello
echo $hello
echo $hello
echo $hello
# Hello!
# Hello!
</syntaxhighlight>
</syntaxhighlight>



2021년 4월 17일 (토) 15:34 판

1 개요

함수 println()
echo
puts
print
  • 변수 출력 + 마지막에 개행문자 출력
  • 함수 print()와 거의 같지만 마지막에 뉴라인을 덧붙여 출력해주는 함수
  • 웹보다는 콘솔에서 필요한 기능

2 Bash

echo hello
echo world
hello='Hello!'
echo $hello
echo $hello

3 Go

package main

import "fmt"

func main() {
    fmt.Println("hello" + "world") // helloworld
    fmt.Println("1+1=", 1+1) // 1+1= 2
    fmt.Println(true)  // true
    fmt.Println(false) // false
    fmt.Println(nil)   // <nil>
}

4 Java

System.out.println("Hello");

5 Perl

use 5.010;
say('hello');
say('world');

6 PHP

echo "Hello!\n";
echo "Hello!\n";
$hello = "Hello!";
echo $hello."\n";
echo $hello."\n";

7 Python

print( "Hello!" )
print( "Hello!" )
# Hello!
# Hello!
hello = "Hello!"
print( hello )
print( hello )
# Hello!
# Hello!

8 Ruby

puts "Hello!"
puts "Hello!"
# Hello!
# Hello!
print "Hello!\n"
print "Hello!\n"
# Hello!
# Hello!
hello = "Hello!"
puts hello
puts hello
# Hello!
# Hello!

9 같이 보기

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