Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Commit

Permalink
fix: Use a local variable to ensure connection is not nil (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoabonizio authored and marceloboeira committed May 10, 2017
1 parent 38b5c0e commit bbe2d3a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/bojack/console.cr
Expand Up @@ -3,6 +3,8 @@ require "bojack-client"

module BoJack
class Console
@client : BoJack::Client?

def initialize(@hostname : String = "127.0.0.1", @port : Int8 | Int16 | Int32 | Int64 = 5000)
begin
@client = BoJack::Client.new(@hostname, @port)
Expand All @@ -13,9 +15,11 @@ module BoJack
end

def start
client = @client
return unless client
loop do
input = Readline.readline("> ", true)
puts @client.send(input)
puts client.send(input)
break if input == "close"
end
end
Expand Down

0 comments on commit bbe2d3a

Please sign in to comment.