1
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?

More than 1 year has passed since last update.

概要

paiza.ioでelixirやってみた。
Record使ってみた。

サンプルコード


require Record

Record.is_record({User, "john", 27})
|> IO.inspect

Record.is_record({})
|> IO.inspect

record = {User, "john", 27}
Record.is_record(record, User)
|> IO.inspect

defmodule User do
	require Record
	Record.defrecord(:user, name: "meg", age: "25")
end
defmodule Main do
    import User
    record = user()				#=> {:user, "meg", 25}
    record = user(age: 26)      #=> {:user, "meg", 26}
    user(record, :name)         #=> "meg"
    user(record, age: 26)       #=> {:user, "meg", 26}
    user(:name)                 #=> 1
    user(record)                #=> [name: "meg", age: 26]
    record = user()             #=> {:user, "meg", 25}
    user(name: name) = record
    name                        #=> "meg"
end

Record.extract(:file_info, from_lib: "kernel/include/file.hrl")
|> IO.inspect



実行結果

true
false
true
[
  size: :undefined,
  type: :undefined,
  access: :undefined,
  atime: :undefined,
  mtime: :undefined,
  ctime: :undefined,
  mode: :undefined,
  links: :undefined,
  major_device: :undefined,
  minor_device: :undefined,
  inode: :undefined,
  uid: :undefined,
  gid: :undefined
]

成果物

以上。

1
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
1
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?