faustinoaq changed the topic of #amber to: Welcome to Amber Framework community! | https://amberframework.org | Developer happiness, productivity and bare metal performance | GH: https://github.com/amberframework | Docs: https://docs.amberframework.org | Gitter: https://gitter.im/amberframework/amber | IRC Logger: https://irclog.whitequark.org/amber | Amber::Server.start
_whitelogger has joined #amber
feepbot has quit [Ping timeout: 246 seconds]
feepbot has joined #amber
<FromGitter> <nsuchy> What mistake am I making here?
<FromGitter> <damianham> user could be Nil
<FromGitter> <nsuchy> @damianham shouldn't the if statement only continue if it gets a truthy value?
<FromGitter> <nsuchy> even checking for nil doesn't fix the problem
<FromGitter> <damianham> I think it is to do with the way Crystal does type checking and checking for Nil
<FromGitter> <nsuchy> so what work around exists?
<FromGitter> <damianham> ```user = User.find(user_id) ⏎ context.current_user = user ⏎ if user && user.is_admin? ⏎ ``` [https://gitter.im/amberframework/amber?at=5d163c72ffd4b84a8fc70c2e]
<FromGitter> <damianham> there is also '.not_nil!' which you can use when you absolutely know it cannot be Nil
<FromGitter> <damianham> i.e. user.not_nil!.is_admin?
_whitelogger has joined #amber
<FromGitter> <nsuchy> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5d163f10676ff14d27410ad9]
<FromGitter> <nsuchy> this ended up working
<FromGitter> <nsuchy> Haha
<FromGitter> <nsuchy> well this is interesting
<FromGitter> <nsuchy> not even unique to not_nil!
<FromGitter> <nsuchy> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5d16433fa611a04ff1951798]
<FromGitter> <nsuchy> works too
<FromGitter> <nsuchy> lol
<FromGitter> <Blacksmoke16> you could prob rewrite that to be a bit cleaner @nsuchy
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5d164ea5676ff14d27419813]
<FromGitter> <Blacksmoke16> something like that maybe
<FromGitter> <Blacksmoke16> avoids the bunch of nested conditional logic
<FromGitter> <Blacksmoke16> is the reasoning why that doesnt wokr