Tag: 切换语句

Ruby:条件矩阵? 有多种情况的情况?

在ruby中,我想知道是否有办法做到以下几点: 我基本上有一个包含四种可能结果的矩阵: A is True, B is True A is True, B is False A is False, B is True A is False, B is False 我想以最干净的“ruby方式”为此写一个测试。 我希望能做类似的事情 case[A,B] when A && B then … when A && !B then … when !A && B then … when !A && !B then … end ……但那不起作用。 […]