Fl4m3Ph03n1x
Is it possible to have neg_float typespec?
Background
I am doing a small function that takes a few parameters. One such parameter is a float() that must be <= 0.
Now, if this was an integer I would simply use neg_integer() from the typespecs.
However, I am using a float() instead. Unfortunately there is no neg_float() typespec that I could find.
Question
Is there a possible way of having a neg_float() typespec, that would only accept float <= 0 ?
Marked As Solved
LostKobrakai
The short answer: no, there is not.
float is the most concrete representation of a float value in typespecs.
Integers not only have pos_*, non_neg_* and neg_* subsets, but also integers as well as integer ranges are allowed as literal values within typespecs. Given the latter having access to the former makes sense. Literal float values are also not supported for float values though.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










