Last active
April 2, 2016 17:22
-
-
Save zofrex/66c7fde5114c5747277c94e15d3ff4dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc is_admin { | |
user_id | |
} { | |
switch $user_id { | |
1 - | |
3 - | |
5 { return true } | |
default { return false } | |
} | |
} | |
rename if if_old | |
proc if { | |
condition | |
block | |
} { | |
if_old {$condition == {[is_admin $user_id]}} { | |
upvar user_id user_id | |
if_old {$user_id == 22157} { | |
uplevel 1 $block | |
} | |
} else { | |
set result [uplevel 1 expr $condition] | |
if_old {$result} { | |
uplevel 1 $block | |
} | |
} | |
} | |
set user_id 22157 | |
if {[is_admin $user_id]} { | |
puts "$user_id is an admin and can do admin things" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment