# Logic Operator

Logical merupakan operator untuk membandingkan 2 tipe data boolean. Operator ini memiliki operasi AND, OR, NOT/negasi yang masing-masing menggunakan tanda &&, || dan tanda !.

## Contoh code operator logic pada string

```go
package main

import (
	"fmt"
)
func main() {
	var str1 string = "Test1"
	var str2 string = "Testb"
	var str3 string = "test1"
	fmt.Println(str1 == str2 && str1 != str3) 	// (0*1) : false
	fmt.Println(str1 == str2 || str1 != str3)   // (0+1) : true
	fmt.Println(!(str1 == str2))				// true
}
```

```
false
true
true
```

## Contoh code operator logic pada boolean

```go
package main

import (
	"fmt"
)

func main() {
   var bool1 bool = false
   var bool2 bool = true

   fmt.Println(bool1 && bool2)
   fmt.Println(bool1 || bool2)
   fmt.Println(!bool1)
   fmt.Println(!bool2)
}
```

```
false
true
true
false
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rafli-ramadhan.gitbook.io/golang-example-code-by-topic/operator-di-golang/logic-operator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
