工程师的自我修养
来源:互联网 发布:彩视官网 软件 编辑:程序博客网 时间:2024/04/28 02:54
背景
要根据scope来设置一个class我写的
if current_path.split('?')[0] == tags_console_tickets_path klass = scope == "tags_all" ? "current" : nilelse klass = ((params[:scope] and params[:scope] == scope.to_s) or (params[:scope].blank? and scope.to_s == "unclosed_and_assigned_me_and_last_replied_not_me")) ? "current" : nilend
老大review后
klass = \ if request.path == tags_consile_tickets_path "current" if scope.to_s == "tags_all" elsif params[:scope].present? "current" if params[:scope] == scope.to_s else "current" if scope.to_s == "unclosed_and_assigned_me_and_last_replied_not_me" end
然后我在来
klass = \ if request.path == tags_console_tickets_path # tags_all "current" if scope == :tags_all elsif params[:scope].present? # status, assigner, tags etc.. "current" if scope.to_s == params[:scope] end
老大批语
三元运算符是为了方便才存在的,写的跟看的人都不方便,就不要用了
我的感受
这里本来就写的比较复杂,然后我为了追求同样炫酷(主要是懒。。),稍微改改发现能用就扔那了。工程师的自我修养还是不到家。。
0 0
- 工程师的自我修养
- 工程师的自我修养
- 谈测试工程师的自我修养
- 【系统工程师的自我修养】sed篇
- Google工程师谈程序员的自我修养
- 《Web全栈工程师的自我修养》
- 《web全栈工程师的自我修养》
- 论软件开发工程师的自我修养
- 一个前端工程师的自我修养
- 前端工程师の自我修养
- 《web全栈工程师的自我修养》读书笔记
- Web全栈工程师的自我修养——读书笔记
- Web全杖工程师的自我修养 总结1
- Web全栈工程师的自我修养 心得2
- 《Web全栈工程师的自我修养》读书笔记
- 《web全栈工程师的自我修养》浅谈
- 《web全栈工程师的自我修养》读书笔记
- 《Web全栈工程师的自我修养》读后感
- 重构——重新组织你的函数
- CSS系列1-块级元素VS行内元素
- 微博的几个小功能
- 彻底理解字符串
- 2014年学习总结
- 工程师的自我修养
- 螺旋矩阵的两种JAVA实现
- 求全排列
- 【机器学习快讯】20150124第一篇机器学习快讯
- 重构——重新组织你的函数
- ssh登录远程服务器修改gcc版本
- CentOS6.5 FTP配置
- 【LeetCode】Min Stack && 【九度】题目1522:包含min函数的栈
- 解决树莓派连载路由器上后无法解析域名导致无法上网的问题