我有:
@fruit = ["Apples, Oranges, Bananas", "Apples", "Bananas, Pears", "Bananas, Apples, Pears", "Pears"]
Run Code Online (Sandbox Code Playgroud)
我想用它做两件不同的事情,先把它变成一个纯数组,每个只有一个实例:
["Apples", "Oranges", "Bananas", "Pears"]
Run Code Online (Sandbox Code Playgroud)
其次,我希望能够确定数组中给定实例的数量:
@fruit.count("Apples") = 3
Run Code Online (Sandbox Code Playgroud)
第三,是否可以按实例数量对数组进行排序:
@fruit.sort = ["Apples", "Apples", "Apples", "Bananas", "Bananas", "Bananas", "Pears", "Pears", "Pears", "Oranges"]
Run Code Online (Sandbox Code Playgroud)
我必须使用什么数组/字符串函数来执行此操作?
我无法弄清楚这一点.我已经完成了研究,请不要评论我做更多的研究.此外,我是一个菜鸟,所以要好;)
这是我的网站:http://library.skybundle.com/
将鼠标悬停在主蓝色导航栏(标题区域)中的两个黑色矩形上.a:悬停应该使颜色变为灰色.问题是在Chrome中,这看起来很完美.但是,在Firefox中,填充权限不够长或者其他东西,所以"教育课程"按钮的最右侧总是有一个小的黑色矩形(只有当光标悬停在按钮上时才会显示).换句话说,鼠标悬停时灰色框不会一直到按钮区域的右侧端.我只是不明白为什么这在Chrome中看起来效果很好,但在Firefox中却有问题......
相信我,当我说我已尝试使用Firebug在Firefox中修复它时所做的一切.如果您使用浏览器中的编辑器来玩它,您会看到如果您尝试为Firefox填充更长时间,它会将整个按钮弹出一个新行.因此,为了解决这个问题,你必须使容器更宽,但原来的问题又回来了.这是一个问题圈,我相信你们中的一个天才会看到一个我想念的简单解决方案.
请帮忙.谢谢!
编辑:
这是我的JSFiddle和代码.请注意它在Chrome中看起来很棒但在Firefox中看起来不是很好
HTML:
<div id="navigation">
<div id="navigation-inner">
<div id="page-nav">
<div id="primary-nav">
<ul id="top-menu">
<li id="li-left"><a href="#">Product Training Videos</a></li>
<li id="li-right"><a href="#">Educational Courses</a></li>
</ul>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
#navigation {
background: url(http://library.skybundle.com/wp-content/themes/business-services/library/styles/colour-images/mu-nav.jpg) repeat-x;
margin: 0px;
padding: 0px;
height: 40px;
width: 100%;
}
#navigation-inner {
margin: 0px auto;
padding: 0px;
height: 48px;
width: 960px;
}
#page-nav {
margin: 0px;
padding: 0px;
height: 40px;
width: 960px;
}
div#primary-nav {
position: relative;
display: block; …Run Code Online (Sandbox Code Playgroud) 在Rails 4中我想在设计卖家中创建一个包含产品的订单,我使用gem"cocoon"
class Seller < ActiveRecord::Base
has_many :orders
class Order < ActiveRecord::Base
belongs_to :seller
has_many :products
accepts_nested_attributes_for :products, allow_destroy: true
class Product < ActiveRecord::Base
belongs_to :order
Run Code Online (Sandbox Code Playgroud)
我想在new.html中创建,但卖家不需要登录,我希望它可以通过URL
new.html
<%- model_class = Order -%>
<%= simple_form_for @order, :html => { :class => 'form-horizontal' } do |f| %>
<%= f.simple_fields_for :products do |product| %>
<%= render 'product_fields', :f => product %>
<% end %>
<%= link_to_add_association 'add product', f, :products %>
<%= f.button :submit, :class => 'btn-primary' %>
<% end %>
in …Run Code Online (Sandbox Code Playgroud) 我是Ada的新手,我正在尝试创建一个记录数组,然后将一些记录放到数组中,但是我得到了错误nested array aggregate expected.这是我的代码:
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_Io;
with Ada.unchecked_conversion;
procedure main is
type Byte is range 0..255;
for Byte'Size use 8;
type Pixel is record
R:Byte;
G:Byte;
B:Byte;
end record;
for Pixel'Size use 24;
r1:Pixel := (1,2,5);
r2:Pixel := (1,2,3);
r3:Pixel := (1,2,3);
type Image is array(Positive range <>, Positive range <>) of Pixel;
Pragma Pack(Image);
Left:Image(1..3, 1..1) := (r1, r2, r3);
begin
null;
end main;
Run Code Online (Sandbox Code Playgroud)