小编Pat*_*ney的帖子

难以解决基本的 RubyMonk 练习

在此页面上:\n https://rubymonk.com/learning/books/4-ruby-primer-ascent/chapters/45-more-classes/lessons/105-equality_of_objects

\n\n

我正在尝试更正此代码,以便它通过测试。\n我的尝试非常糟糕,因为我才刚刚开始学习软件逻辑的工作原理。

\n\n
class Item\n    attr_reader :item_name, :qty\n\n    def initialize(item_name, qty)\n        @item_name = item_name\n        @qty = qty\n    end\n    def to_s\n        "Item (#{@item_name}, #{@qty})"\n    end\n\n    def ==(other_item)\n    end\nend\n\np Item.new("abcd",1)  == Item.new("abcd",1)\np Item.new("abcd",2)  == Item.new("abcd",1)\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我的解决方案,但它不正确:

\n\n
class Item\n    attr_reader :item_name, :qty\n\n    def initialize(item_name, qty)\n        @item_name = item_name\n        @qty = qty\n    end\n    def to_s\n        "Item (#{@item_name}, #{@qty})"\n    end\n\n    def ==(other_item)\n       if self == other_item\n         return true\n       else\n         return false\n       end\n    end\nend\n\np Item.new("abcd",1)  == Item.new("abcd",1)\np Item.new("abcd",2)  == Item.new("abcd",1)\n
Run Code Online (Sandbox Code Playgroud)\n\n

我希望 …

ruby

2
推荐指数
1
解决办法
889
查看次数

非常基本连接到mysql/test问题

如果这是一个非常愚蠢的问题,我会提前道歉(我是php和mysql的新手.

基本上,我正在设置connect_to_mysql.php文件,如下所示(5:50):http://www.youtube.com/watch?v = YaII5QhNCH0

如下图所示:http: //www.developphp.com/view_lesson.php?v = 248

我正在使用MAMP.端口是80/3306然而我知道在MAMP起始页面上说,以下,它也不起作用:

MySQL的

可以使用phpMyAdmin管理MySQL数据库.

要从您自己的脚本连接到MySQL服务器,请使用以下连接参数:

主机:localhost端口:3306用户:root密码:root

这是我有的:

这是connect_to_mysql.php:

        <?php  
    // Created BY Adam Khoury @ www.flashbuilding.com - 6/19/2008  
/*  
1: "die()" will exit the script and show an error statement if something goes wrong with     the     "connect" or "select" functions. 
2: A "mysql_connect()" error usually means your username/password are wrong  
3: A "mysql_select_db()" error usually means the database does not exist. 
*/ 
// Place db host name. Sometimes …
Run Code Online (Sandbox Code Playgroud)

php mysql dreamweaver

1
推荐指数
1
解决办法
3239
查看次数

标签 统计

dreamweaver ×1

mysql ×1

php ×1

ruby ×1