Skip to content

Commit 0f9b717

Browse files
committed
Improve IEX's s helper implementation
1 parent 295d275 commit 0f9b717

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lib/iex/lib/iex/helpers.ex

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -369,18 +369,14 @@ defmodule IEx.Helpers do
369369

370370
@doc false
371371
def s(module, function, arity) do
372-
case Enum.filter(beam_specs(module),
373-
fn({_type, {{f,a}, _value}}) ->
374-
f == function and a == arity
375-
end) do
376-
[spec] -> :ok
377-
_ -> spec = nil
372+
specs = lc {_kind, {{f, a}, _spec}} = spec inlist beam_specs(module),
373+
f == function and a == arity do
374+
print_spec(spec)
375+
spec
378376
end
379377

380-
if spec do
381-
print_spec(spec)
382-
else
383-
IO.puts "No specs for #{inspect module}.#{function}/#{arity} have been found"
378+
if specs == [] do
379+
IO.puts "No specs for #{inspect module}.#{function} have been found"
384380
end
385381

386382
:ok

0 commit comments

Comments
 (0)