ENV =发展
任何想法为什么
List<Person> persons = IntStream.rangeClosed(0, 100)
.mapToObj(i -> new Person(i, "name" + i))
.collect(Collectors.toList());
正在抛出错误
def tidy_address(location)
t_address=t_address+"<br>"+location.address1 if location.address1.present?
t_address=t_address+"<br>"+location.address2 if location.address2.present?
t_address=t_address+"<br>"+location.address3 if location.address3.present?
t_address=t_address+"<br>"+location.postcode if location.postcode.present?
end
我似乎将一个方法应用于字符串,但我不知道如何解决此问题
也尝试了
undefined method `+' for nil:NilClass
接受Boozy建议
答案 0 :(得分:-2)
Doooh ......
所以这解决了它 - 我是一个旧的ASP黑客,它很懒惰
def tidy_address(location)
t_address="<br>"+location.address1 if location.address1.present?
t_address=t_address+"<br>"+location.address2 if location.address2.present?
t_address=t_address+"<br>"+location.address3 if location.address3.present?
t_address=t_address+"<br>"+location.postcode if location.postcode.present?
end