Skip to content

Update mappings.md #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions de/1/mappings.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
<!-- Add translation for the following page: https://vyper.fun/#/1/mappings
Do NOT change the code below. The below code runs the code editor -->

# Chapter 5: Mappings

Im vorigen Chapter haben wir uns mit Strukturen beschäftigt. Mappings sind eine andere Art, in Vyper organisierte Daten zu speichern.

Mappings sind [Hashtabellen](https://de.wikipedia.org/wiki/Hashtabelle) die virtuell initialisiert sind, so dass jeder mögliche Key schon existiert und auf einen Defaultwert zeigt.

Ein Mapping wird auf folgende Art erstellt:

```vyper
# ein Mapping um Matrikelnummern und Namen von Studenten zu speichern
exampleMapping1: HashMap[uint256, String[64]]

# ein Mapping um Usernames und Followeranzahl zu speichern
exampleMapping2: HashMap[String[32], uint256]
```

Ein Mapping dient um Werte unter einem bestimmten Key zu speichern und wieder aufzurufen. Im ersten Mapping `exampleMapping1` ist der Key ein `uint256` und der Wert ein `String[64]`. Im zweiten Mapping, `exampleMapping2`, ist der Key ein `String[32]` und der Wert ein `uint256`.

## Stellen Sie sich auf die Probe


Um unsere Pokemons zu speichern werden wir ein Mapping brauchen, dass unsere Pokemons mit einer Seriennummer verbindet.

1. Erstellen Sie ein Mapping mit dem Namen `pokemonList`, mit einem `uint256` Key und einem Wert vom Typ ´Pokemon´

<!-- tabs:start -->

#### ** Template **
Expand Down