Elseif, ellse, why read(stdin,Char) not works in Julia 0.7?

Why not works else take() after enter ‘s’ to take()

function take()
global agreement=read(stdin,Char)
end

take()
s

if agreement=='y' ; 
elseif agreement=='n' ; 
else take()
end

Works for me

Starting Julia...
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _  |  |
  | | |_| | | | (_| |  |  Version 1.1.1 (2019-05-16)
 _/ |\__ _|_|_|\__ _|  |  Official https://julialang.org/ release
|__/                   |

julia> function take()
       println("Now inside function take()")
       global agreement=read(stdin,Char)
       end
take (generic function with 1 method)

julia> take()
Now inside function take()
s
's': ASCII/Unicode U+0073 (category Ll: Letter, lowercase)

julia> if agreement=='y' ; 
              elseif agreement=='n' ; 
              else take()
              end
Now inside function take()
g
'g': ASCII/Unicode U+0067 (category Ll: Letter, lowercase)
1 Like
1 Like