http://docs.ruby-lang.org/en/2.0.0/Hash.html

invert → new_hash
Returns a new hash created by using hsh's values as keys, and the keys as values. h = { "n" => 100, "m" => 100, "y" => 300, "d" => 200, "a" => 0 }
h.invert #=> {0=>"a", 100=>"m", 200=>"d", 300=>"y"}
 <td class="recommend"><%= subchannel_item.if_recommend %></td>
  RECOMMEND = {
'否' => false,
'是' => true
}
  def if_recommend
RECOMMEND.invert[recommend]
end
[11] pry(main)> SubchannelItem::RECOMMEND
=> {"否"=>false, "是"=>true}
[12] pry(main)> SubchannelItem::RECOMMEND.invert
=> {false=>"否", true=>"是"} [15] pry(main)> SubchannelItem::RECOMMEND.invert[SubchannelItem.first.recommend]
=> "是"

invert的更多相关文章

  1. [LeetCode] Invert Binary Tree 翻转二叉树

    Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia: This problem wa ...

  2. 《Invert》开发日志05:终止

    今天终于看了久闻大名的<独立游戏大电影>,然后我就做了一个坑爹的决定:终止“Invert”项目的开发.没错,在还没正式开工之前,我就决定停掉这个项目,而且是永久终止.做这个决定并不是因为觉 ...

  3. 《Invert》开发日志04:工具、资源和服务

    这篇记录一下<Invert>用到的工具.资源和服务.秉承两个原则:一,绝不侵犯版权:二,尽量节省开支. 首先是工具.游戏引擎使用免费的Unity个人版: 编码IDE使用免费的VisualS ...

  4. Invert Binary Tree

    Invert a binary tree: 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 简单递归实现,调换左右子树,子树的所有子树结构 ...

  5. $.grep(array, callback, [invert])过滤,常用

    $.grep(array, callback, [invert])过滤,常用 解释: 使用过滤函数过滤数组元素.此函数至少传递两个参数(第三个参数为true或false,对过滤函数返回值取反,个人觉得 ...

  6. 《Invert》开发日志01:核心玩法设计

    前面提过,这个游戏的核心玩法基于我做的第一个Unity游戏,名字就叫<Invert>,现在在应用宝上面还能搜到.不过那个游戏也不是我原创的,它的玩法设计来自github上的一个开源项目(h ...

  7. Leetcode 226. Invert Binary Tree

    Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 class Solution(object): ...

  8. C#编写滤镜 图片色调取反效果(Invert)

    转自:http://www.it165.net/pro/html/201208/3469.html Invert 英文叫做颠倒.. 原理很简单也就是 将 255- 原本的值.. 这样 0(黑) 就会变 ...

  9. Java for LeetCode 226 Invert Binary Tree

    Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia: This problem wa ...

  10. 【07_226】Invert Binary Tree

    Invert Binary Tree Total Accepted: 54994 Total Submissions: 130742 Difficulty: Easy Invert a binary ...

随机推荐

  1. Mediator Pattern --中介者模式原理及实现(C++)

    主要参考<大话设计模式>和<设计模式:可复用面向对象软件的基础>两本书.本文介绍中介者模式的实现. 中介者模式:What it is:Define an object that ...

  2. 【BZOJ1011】【HNOI2008】遥远的行星(乱搞)

    1011: [HNOI2008]遥远的行星 Time Limit: 10 Sec  Memory Limit: 162 MBSec  Special JudgeSubmit: 1444  Solved ...

  3. 第四课:seajs的模块编译_compile过程

    最近比较闲,我就讲下seajs的模块编译_compile过程. 这里紧接着第三课的例子来讲解.首先是a.js的编译 Module.prototype._compile = function() { 1 ...

  4. mysqld参数配置

    这个文件超级大, 查了一下, 大概的作用如下 是储存的格式INNODB类型数据状态下,ibdata用来储存文件的数据而库名的文件夹里面的那些表文件只是结构而已 由于mysql4.1默认试innodb, ...

  5. “耐撕”2016.04.13站立会议

    1. 时间 : 19:40--20:00  共计20分钟 2. 人员 : Z   郑蕊 * 组长 (博客:http://www.cnblogs.com/zhengrui0452/), P 濮成林(博客 ...

  6. 小结-Splay

    参照陈竞潇学长的模板写的BZOJ 3188: #include<cstdio> #include<cstring> #include<algorithm> #def ...

  7. hdu4287 字典树

    #include<stdio.h> #include<string.h> #include<stdlib.h> #define maxn 10 struct tri ...

  8. 【POJ 1416】Shredding Company

    题 题意 给你一个target number,和一个最多六位的数num,让你把数分段,使总和最接近但不大于target number. 如果只有一种方法就输出总和.分段,如果有多种方法,输出rejec ...

  9. 【BZOJ-2818】Gcd 线性筛

    2818: Gcd Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 3347  Solved: 1479[Submit][Status][Discuss ...

  10. POJ2299 Ultra-QuickSort

    Description In this problem, you have to analyze a particular sorting algorithm. The algorithm proce ...