IMO the parametric method with multiple dispatch is more Julian.
or, the more specific
function read_integer(prompt::String="")::Int
print(prompt)
str = chomp(readline())
return parse(Int, str)
end
On Friday, October 28, 2016 at 1:17:54 AM UTC-4, Jeffrey Sarnoff wrote:
>
> with Yichao's help,
>
>
>
> typealias ParseableNumber Union{Float64, Float32,
with Yichao's help,
typealias ParseableNumber Union{Float64, Float32, Signed, Unsigned, Bool}
"""
`input{T<:ParseableNumber}(::Type{T}, prompt::String="")::T`
Read an integer or a floating point value from STDIN.
The prompt string, if given, is printed to standard output without a
trail
Thank you, that is helpful.
On Friday, October 28, 2016 at 12:22:37 AM UTC-4, Yichao Yu wrote:
>
> On Fri, Oct 28, 2016 at 12:01 AM, Jeffrey Sarnoff
> > wrote:
> > And although readline() yields a String, if you are asking for, say, a
> Int
> > or a Float64 value, you can add a second version
On Fri, Oct 28, 2016 at 12:01 AM, Jeffrey Sarnoff
wrote:
> And although readline() yields a String, if you are asking for, say, a Int
> or a Float64 value, you can add a second version of `input`:
>
> ```
> typealias ParseableNumber Union{Float64, Float32, Signed, Unsigned, Bool}
>
> """
> `in
And although readline() yields a String, if you are asking for, say, a Int
or a Float64 value, you can add a second version of `input`:
```
typealias ParseableNumber Union{Float64, Float32, Signed, Unsigned, Bool}
"""
`input{T<:ParseableNumber}(::Type{T}, prompt::String="")::T`
Read an int
"""
`input(prompt::String="")::String`
Read a string from STDIN. The trailing newline is stripped.
The prompt string, if given, is printed to standard output without a
trailing newline before reading input.
"""
function input(prompt::String = "")::String
print(prompt)
return chomp(r
it will be read as a string so you can skip the quotes..
to remove the ballast (single trailing newline from a string) use "chomp"
function
julia> user_input = chomp(readline());
asd
julia> user_input
"asd"
On Thursday, October 27, 2016 at 5:16:25 PM UTC+2, Aleksandr Mikheev wrote:
>
> Hello,
Okay, I accidentally figured the answer for the P.S. by myself.
четверг, 27 октября 2016 г., 18:16:25 UTC+3 пользователь Aleksandr Mikheev
написал:
>
> Hello,
>
> How could I input a data from the console? For instance, I would like to
> make such that user is able to input the value of x. Is t