0

#<在 Rails 控制台输出上,以下示例中哈希开头的含义是什么?:

irb(main):003:0> a=Movie.all
Movie Load (0.5ms)  SELECT "movies".* FROM "movies" 
=> [#<Movie id: 1, title: "Aladdin", rating: "G", description: nil, release_date: "1992-11-25 00:00:00", created_at: "2013-07-27 21:29:01", updated_at: "2013-07-27 21:29:01">, #  <Movie id: 2, title: "The Terminator", rating: "R", description: nil, release_date: "1984-10- 26 00:00:00", created_at: "2013-07-27 21:29:01", updated_at: "2013-07-27 21:29:01">, #<Movie id: 3, title: "When Harry Met Sally", rating: "R", description: nil, release_date: "1989-07-21 00:00:00", created_at: "2013-07-27 21:29:01", updated_at: "2013-07-27 21:29:01">,...  more output
4

2 回答 2

1

这就是在 ruby​​ 中打印对象的方式,例如,Movie 类的实例将打印如下:

<#Movie:0x003247fa... >
    |          |
   class      memory position I think

您所拥有的是一组以前的写作:

[ one_object, other_object ... ]

要获得更好的显示效果,您可以使用hirb

于 2013-08-02T16:58:18.650 回答
0

#<表示这是 Movie 类的一个实例。

于 2013-08-02T16:59:00.690 回答