This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Person do | |
defstruct [:name, :age] | |
def with do | |
{Person.Builder, %{}} | |
end | |
defmodule Builder do | |
def unquote(:'$handle_undefined_function')(:and_with, [{__MODULE__, _acc} = tuple]) do | |
tuple |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Mlearning do | |
@moduledoc false | |
def mods(x) do | |
[rem(x, 3), rem(x, 5), rem(x, 15)] | |
end | |
def fizzbuzz(n) do | |
cond do | |
rem(n, 15) == 0 -> [0, 0, 1, 0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/party_web/components/example_component.ex | |
defmodule PartyWeb.ExampleComponent do | |
@moduledoc """ | |
An example LiveComponent under test. | |
""" | |
use Phoenix.LiveComponent | |
def render(assigns) do | |
~H""" | |
<div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.Repo do | |
use Ecto.Repo, | |
otp_app: :my_app, | |
adapter: Ecto.Adapters.Postgres | |
require Ecto.Query | |
@spec fetch_one(Ecto.Queryable.t(), Keyword.t()) :: | |
{:ok, struct()} | {:error, :not_found} | |
def fetch_one(queryable, opts \\ []) do |
OlderNewer