From 8ffa9ade2984d81427edc68aafedd30144aa934b Mon Sep 17 00:00:00 2001 From: Felix Agner <felix.agner@control.lth.se> Date: Tue, 3 Jan 2023 16:06:03 +0100 Subject: [PATCH] tried adding do-type syntax --- src/connectomnibot.jl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/connectomnibot.jl b/src/connectomnibot.jl index 120aa09..ee870fd 100644 --- a/src/connectomnibot.jl +++ b/src/connectomnibot.jl @@ -10,8 +10,23 @@ end """ connectomnibot(ip::IPv4;port::Int) -Also callable with an IPv4 type argument +Connectomnibot is callable with an IPv4 type argument """ function connectomnibot(ip::IPv4, port::Int) return connect(ip,port) end + + +""" + connectomnibot(f::Function, args...) + +Connectomnibot is callable with `do`-functionality +""" +function connectomnibot(f::Function, args...) + bot = connectomnibot(args...) + try + f(bot) + finally + close(bot) + end +end \ No newline at end of file -- GitLab