小编use*_*412的帖子

Haskell如何追加像".. ++ Integer ++ ..."这样的整数

这是我的代码:

func :: Integer -> String
func i = "LoadC R" ++ i ++ "\n"
Run Code Online (Sandbox Code Playgroud)

但是我得到了错误:

无法将预期类型`[Char]'与实际类型`Integer'匹配

我如何转换i为char?

haskell append type-conversion

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

私有方法`new'调用MyReminderMailer:Class

在控制器中,我有:

mailer = MyReminderMailer.new
Run Code Online (Sandbox Code Playgroud)

邮件看起来像这样:

class MyReminderMailer < ActionMailer::Base
  def change_email
    mail(
      from:     default_from,
      to:       default_to,
      subject: "..."
    )
  end

  def default_from
    return '...'
  end

  def default_to
    return '...'
  end
end
Run Code Online (Sandbox Code Playgroud)

但得到错误:私有方法`new'调用MyReminderMailer:Class

ruby actionmailer

3
推荐指数
2
解决办法
3507
查看次数

实现比较,但在调用Arrays.sort时出现异常

这是我的班级:

public static class __9_7_Person implements Comparator<__9_7_Person> {
    private int height;
    private int weight;
    public __9_7_Person(int height, int weight) {
        this.height = height;
        this.weight = weight;
    }
    public int compare(__9_7_Person p1, __9_7_Person p2) {
        if (p1.height != p2.height) {
            return p1.height - p2.height;
        }
        else {
            return p1.weight - p2.weight;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我创建了一个这样的数组:

__9_7_Person p[] = {new __9_7_Person(60, 100),
                    new __9_7_Person(70, 150),
                    new __9_7_Person(56, 90),
                    new __9_7_Person(75, 190),
                    new __9_7_Person(60, 95),
                    new __9_7_Person(68, 110),
};
Run Code Online (Sandbox Code Playgroud)

但是当我调用Arrays.sort(p)时出现异常:"线程中的异常"主"java.lang.ClassCastException:ch_9 $ __ 9_7_Person无法强制转换为java.lang.Comparable"

java comparator

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