这段代码有什么问题?我被期待"titi",person.name但我仍然有"toto"!更明确地说,如何修改函数中的记录?
init1()->
S=#person{name="toto"}, %record creation and field setting
fct(S),
io:format("~s~n",[S#person.name]).
fct(R)->
R#person{name="titi"}. %record updating
Run Code Online (Sandbox Code Playgroud) 由于某种原因,我无法得到这个工作:
void examplefunctionname(string str, ...){
...
va_start(ap, str.c_str());
Run Code Online (Sandbox Code Playgroud)
我也没有得到这个工作:
void examplefunctionname(string str, ...){
...
int len = str.length();
char *strlol = new char[len+1];
for(int i = 0; i < len; i++){
strlol[i] = str[i];
}
strlol[len] = 0;
va_start(ap, strlol);
Run Code Online (Sandbox Code Playgroud)
但这样做:
void examplefunctionname(const char *str, ...){
...
va_start(ap, str);
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我如何使用字符串而不是const char *那里?
我打电话时输出随机数 examplefunctionname("%d %d %d", 1337, 1337, 1337)
可能重复:
在类中创建私有构造函数有什么用?
我们在哪里需要私人构造函数?我们如何实例化一个具有私有构造函数的类?
我正在阅读" 更好,更快,更轻的Java "(由Bruce Tate和Justin Gehtland撰写)并且熟悉敏捷类型团队的可读性要求,例如Robert Martin在其清晰的编码书中所讨论的内容.在我现在的团队中,我被告知明确不使用+运算符,因为它在运行时创建了额外的(和不必要的)字符串对象.
但是这篇文章,写于04年,讨论了对象分配是关于10个机器指令的.(基本上免费)
它还讨论了GC如何帮助降低此环境中的成本.
什么是使用之间的实际性能的权衡+,StringBuilder还是StringBuffer?(就我而言,它StringBuffer仅限于Java 1.4.2.)
StringBuffer对我来说导致丑陋,不太可读的代码,正如Tate的书中的几个例子所示.而且StringBuffer是线程同步的,这似乎有它自己的成本是大于中使用了"危险" +操作.
思想/意见?
我在一个类的列表中有一些元素.我希望它们在新列表中排序,并且必须按照另一个类的属性进行排序.
谁能举个例子?
到目前为止,我的代码如下所示:
class Carcompany:
def __init__(self, model, production_number):
self.model = model
self.production_number = production_number
self.car_list = []
def add_car_to_car_list(self, car):
self.car_list.append(car)
class Info:
def __init__(self):
self.license_plate_number = []
def add_license_plate_to_list(self, license_plate):
self.license_plate_number.append(license_plate)
Run Code Online (Sandbox Code Playgroud)
我需要self.car_list排序self.license_plate_number- 最高编号.我不知道到底有多少我不知道.我感谢任何帮助,我可以得到:)
我在jbpm.jar中有一个名为org.jbpm.task.Comment的类.
但是,这是一个CR1版本,并且我希望我的应用程序覆盖该类中的错误.
在com.jbpm.task下我的项目中有一个名为Comment的类是不是很好,甚至在其他的罐子里它都会引用我的?
我的命名空间声明如下所示:
(ns test.foo
(:use
[clj-http.client :only (get) :as client]
[net.cgrand.enlive-html :only (select) :as html]))
Run Code Online (Sandbox Code Playgroud)
它在REPL中工作正常,这是我第一次使用它.然后,当我修改代码并在REPL中尝试以下内容时:
(use :reload 'test.foo)
Run Code Online (Sandbox Code Playgroud)
我明白了:
java.lang.IllegalStateException: get already refers to: #'clj-http.client/get in namespace: test.foo (foo.clj:1)
Run Code Online (Sandbox Code Playgroud)
我在逆时针方向的窗户上,也尝试了leiningen(lein repl).
我试图从Firefox扩展访问页面的localStorage.我的理解是content提供window对当前页面的引用.当我尝试访问该页面的localStorage时content.localStorage,我想我正在获取它的引用.但是,当我尝试时content.localStorage.length,我什么都没得到.
附件是有问题的代码.
var myExtension = {
init: function() {
var appcontent = document.getElementById("appcontent"); // browser
if(appcontent)
appcontent.addEventListener("DOMContentLoaded", myExtension.onPageLoad, true);
},
onPageLoad: function(aEvent) {
var doc = aEvent.originalTarget;
alert(content.localStorage) // alerts "[object XPCNativeWrapper [object Storage]]"
alert(content.localStorage.length) // alerts nothing
}
window.addEventListener("load", function() { myExtension.init(); }, false);
Run Code Online (Sandbox Code Playgroud)
编辑#1:更多信息.
try{
alert(content.localStorage.getItem('todoData'))
alert(content.localStorage.length)
} catch (e){
alert(e)
}
Run Code Online (Sandbox Code Playgroud)
长度抛出异常"[Exception ..."组件不可用"nsresult:"0x80040111(NS_ERROR_NOT_AVAILABLE)"
localStorage.length当我在Firefox的标准网页上使用它时,它可以content.localStorage.length工作,但不适用于Firefox扩展.现在我很困惑......
我有几个相同类型的bean(BeanType).如何通过带注释的ID注入它们?说:
@Autowired @ID("bean1")
public void setBean( BeanType bean ) {
}
Run Code Online (Sandbox Code Playgroud)
但是没有注释@ID.
我只发现@Qualifier这意味着我必须提供所有的bean ID 和限定符.当然,还有一种更简单的方法吗?
我写了一个脚本,它使用Rails对Ruby核心Object类的扩展,现在我想把它自己分开.而不是重写这些,是否有任何我可以使用的库或扩展来使它们独立可用?
c++ ×2
java ×2
annotations ×1
clojure ×1
erlang ×1
html5 ×1
javascript ×1
performance ×1
python ×1
readability ×1
record ×1
ruby ×1
sorting ×1
spring ×1