2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

elixirにおける%の役割

Posted at

はじめに

elixirにおいて % はいくつかの用途によって使われている
比較的頻繁に目にするので知っておくとコードを読む力に直結すると考えられる

%{}の使い方

%{}で使うとマップとして使うことができる
なおマップとはキーと値のペアを複数持つデータ構造のことである

例:
iex > %{}

参考
Elixir 実践入門 基本文法、Web開発、機械学習、IoT
P.48 マップ-複数のキーと値のペアを表す型

%hogehoge{}

構造体
構造体は拡張されたマップのようなもの
キーの形式が厳密に定められており、アトムである必要があります。
構造体は、モジュールの中で、適切なデフォルト値とともに定義される必要があります。
ルールを持つマップと言えます

引用
https://dev.to/nabbisen/-elixir---508k

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?