草庐IT

dynamic-properties

全部标签

properties - 在 Kotlin 中访问属性委托(delegate)

Kotlin具有委托(delegate)属性,这是一个非常好的特性。但有时get()和set()方法是不够的。假设我想懒惰地创建一个Closeable对象并稍后关闭它。以下是如何实现此类委托(delegate)属性的示例:funcloseableLazy(initializer:()->T)=CloseableLazyVal(initializer)classCloseableLazyVal(privatevalinitializer:()->T):ReadOnlyProperty{privatevarvalue:T?=nulloverridefunget(thisRef:Any?,d

node.js - 类型错误 : Cannot read property 'findOne' of undefined

代码如下varmongo=require('mongodb');vardatabaseName='Starter',collectionName='wines';varServer=mongo.Server,Db=mongo.Db,BSON=mongo.BSONPure;db=newDb(databaseName,server);db.open(function(err,db){if(!err){console.log("Connectedto'winedb'database");db.collection(collectionName,{strict:true},function(e

java - 映射异常 : "No property found on entity to bind constructor parameter to"?

我的项目是用springdatamongodb开发的,以前有这个文档:@Document(collection="Instrument")publicclassInstrument{@IdprivateIntegerid;privateStringname;privateStringinternalCode;privateStringfosMarketId;privateStringlocalCode;//setters...getters...andconstructurs....现在我需要向我的文档添加一些属性,如下所示:....privateLongfrom;privateLon

javascript - Node.JS/ express /蒙戈 : TypeError: Cannot read property 'location' of undefined

我一直在寻找这个问题的其他解决方案,但我在其他地方看到的解决方案似乎都不适合我。我有一个要提交给数据库的表单。我正在使用node.JS、express、mongo和pug来呈现HTML。这是我的表格:.modal-contentform(method='POST'action='/insert'id='newReminders')input(type='text'name='location'id='location'placeholder='location')brinput(type='textarea'name='reminder'rows='4'id='reminder'pla

node.js - 使用 mongoose 连接到 mongodb 时出现 "Cannot read property ` 消息 ` of null"

我正在为我的MEAN应用创建行走骨架。我已成功连接到mongodb(已打开multivisiondb),但继续进行时,我在尝试将消息打印到浏览器窗口时收到标题中描述的错误:mongoose.connect('mongodb://localhost/multivision');vardb=mongoose.connection;db.on('error',console.error.bind(console,'connectionerror...'));db.once('open',functioncallback(){console.log('multivisiondbopened')

mysql - 带有 glassfish v3 的 jdbc 领域 : Realm properties and configuration error

我有以下数据库架构(MySQL):我的登录是一个基于表单的身份验证系统,我正在尝试为其创建一个jdbc领域。我的web.xml:FORMemdJDBCRealm/index.jsp/WEB-INF/loginerror.jspLoginPage/*admusrCONFIDENTIALusradm以及sun-web.xml中的映射:admadmusrusr我不知道为什么,但它对我不起作用,我得到以下信息:FINE:Cannotloadgroupcom.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:Unknowncolumn'g

android - Kotlin "Smart cast is impossible, because the property could have been changed by this time"

当我使用No.2脚本时,为什么AndroidStudio会显示错误。我发现1和2没有区别。classAdapter{varnameList:ArrayList?=null}classProgram{privatefunsend(){vallist:ArrayList=ArrayList()valadapter=Adapter()//Case1varotherList=adapter.nameListif(otherList!=null){list.addAll(otherList)///*=java.util.ArrayList*/'isimpossible,because'adapt

android - Kotlin "Smart cast is impossible, because the property could have been changed by this time"

当我使用No.2脚本时,为什么AndroidStudio会显示错误。我发现1和2没有区别。classAdapter{varnameList:ArrayList?=null}classProgram{privatefunsend(){vallist:ArrayList=ArrayList()valadapter=Adapter()//Case1varotherList=adapter.nameListif(otherList!=null){list.addAll(otherList)///*=java.util.ArrayList*/'isimpossible,because'adapt

php - "Property access is not allowed yet"使用准备语句时的警告

这个问题在这里已经有了答案:mysqli+xdebugbreakpointafterclosingstatementresultinmanywarnings(6个答案)关闭2年前。我正在尝试通过使用AES_ENCRYPT()对我的密码进行编码来创建登录系统。但是在尝试实现这些代码时,我从xdebug收到了一些警告:...$key='d0gis=SUPER-cute';$sql="SELECT*FROM`users2`WHEREusername=?ANDpwd=AES_ENCRYPT(?,?)";$stmt=$conn->stmt_init();$stmt->prepare($sql);

iphone - @property (nonatomic, assign) id <IconDownloaderDelegate> 委托(delegate);

谁能解释一下这行是什么意思?我曾经看到(nonatomic,retain)这是我第一次看到“assign”关键字:@property(nonatomic,assign)iddelegate;谢谢你的帮助,史蒂芬 最佳答案 基于Peter的回答:创建属性时,可以使用@synthesize指令自动创建getter和setter方法。编译器不仅创建了两个方法-(id)delegate;-(void)setDelegate:(id)newDelegate;但也为此添加了额外的代码,以防止多个线程同时更改该属性(本质上是一个锁)。nonato