# 컬렉션

모든 <kbd>stype</kbd> 변수는 Solidity 컬렉션에 저장할 수 있으며, 그 동작은 일반적인 비차폐 값들과 동일합니다. 이러한 컬렉션에서 값으로 사용될 때는 기본적으로 정상적으로 동작합니다. 하지만 키와 값으로 동시에 사용될 때는 흥미로운 특성이 나타납니다. 특히 배열과 맵에서 그렇습니다:

```solidity
suint256[] a;  // stype을 값으로 사용
function f(suint256 idx) {
    a[idx]  // stype을 키로 사용
    // ...
}

// ==========

mapping(saddress => suint256) m;  // stype을 키와 값으로 사용
function d(suint256 k) {
    m[k]
}
```

여기서 특별한 점은 `a[idx]`와 `m[k]`를 보관하면서 컬렉션 내에서 어떤 값을 참조하는지 관찰자가 알지 못한다는 것입니다. 이러한 참조에서 값을 읽거나 쓸 수 있습니다:

```solidity
sbool b = a[idx] < 10;
suint256 s = m[k] + 10;
```

이 참조에 값을 쓸 수도 있습니다:

```solidity
a[idx] *= 3;
m[k] += a[idx];
```

이 연산에 대한 관찰자는 읽거나 쓴 요소가 무엇인지 알 수 없습니다.

<figure><img src="/files/PzgsISZsDWv2UoNHTEvD" alt=""><figcaption></figcaption></figure>

***

컬렉션의 키와 값으로 stype을 사용하면, 어떤 요소를 사용하고 있는지를 차폐할 수 있습니다.

이전 섹션에서는 특정 요소에서 발생하는 일만 차폐하는 방법을 알았습니다. 이제 어떤 요소들이 수정되고 있는지를 차폐할 수 있는 방법도 알게 되었습니다.

***

ERC20 변형 예시를  [기본](/seismic-docs-kr/undefined-3/undefined.md)섹션에서 논의한 대로 확장하여, 차폐된 잔액, 전송 금액, 그리고 이제 수신자까지 차폐할 수 있습니다:

```solidity
mapping(saddress => suint256) public balanceOf;  // 키는 이제 saddress

function transfer(saddress to, suint256 amount) public {  // 수신자는 이제 saddress
    balanceOf[msg.sender] -= amount;
    balanceOf[to] += amount;
}
```


---

# 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://clairetranslation.gitbook.io/seismic-docs-kr/undefined-4.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.
