methods

Why do new and object.create behave differently in this example

耗尽温柔 提交于 2019-12-11 16:53:33
问题 In this simple example, why do new and Object.create behave differently? var test=function(name){ this.name=name }; var test1= new test("AAA"); test1.name;//AAA var test2=Object.create(test); test2.name="AAA"; typeof(test2);//Object test2.name;//"" (empty string). Why is test2.name empty? 回答1: Object.create expects an Object as it's first argument for the prototype chain, not a function (or constructor in your case). It won't complain if you pass a function , but it means that certain extra

How Do I Use A Variable In One Method If It Was Declared In A Different Method? C#

╄→гoц情女王★ 提交于 2019-12-11 16:49:30
问题 So I'm trying to figure out the easiest way to "reuse" a variable from a previous method, but cant find exactly what I'm looking for anywhere. Basically I have a simple program that uses openFileDialog to open a text file(this happens in one button click). In another button click it write what I wrote to the file. the issue I'm Having is writing the file, because I cant reuse the path variable from method 1 :/ Here's my Code: public void button1_Click(object sender, EventArgs e) {

Optimize MySQL search process

纵饮孤独 提交于 2019-12-11 16:46:16
问题 Here is the scenario 1. I have a table called "items", inside the table has 2 columns, e. g. item_id and item_name . I store my data in this way: item_id | item_name Ss001 | Shirt1 Sb002 | Shirt2 Tb001 | TShirt1 Tm002 | TShirt2 ... etc, i store in this way: first letter is the code for clothes, i.e S for shirt, T for tshirt second letter is size, i.e s for small, m for medium and b for big Lets say in my items table i got 10,000 items. I want to do fast retrieve, lets say I want to find a

Python getting a variable in a class [closed]

柔情痞子 提交于 2019-12-11 16:43:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'm learning right now a python language but I would like to programm in OOP style. Sorry for my questions but in my book and a video tutorial I couldn't find an answer. I know there is easer way to get a number without a method... but I would like to do it in a class ;) I would like to read a number from a user

Objective C Methods and syntax

不问归期 提交于 2019-12-11 16:32:32
问题 I am a bit confused when working with objective-c. This part in particular confuses me a lot. What is the purpose and/ or difference between writing code like this ... object = [object method]; and [object method]; Learning objective-c up until now, I always assumed that I could do something like this.. say I had already created this.. NSString *object = [[NSString alloc]initWithFormat:@"%@"]; then I could do what I want with that like so.. [object applyAnyMethodHere]; but now I'm seeing

Creating a class that handles postgresql queries in C#

不羁的心 提交于 2019-12-11 16:19:36
问题 My question is: What's the most efficient way to handle bunch of postgresql queries inside a new class/method that have different SQL queries, parameters and return values? For example: NpgsqlCommand ukupno_sati = new NpgsqlCommand("begin;select cast(radni_sati.sati_rada as time) from radni_sati where zaposlenik_id=@zaposlenik_id " + " and extract(month from radni_sati.datum)=@mjesec_broj and extract(year from radni_sati.datum)=@godina;commit;",conn); ukupno_sati.Parameters.AddWithValue("

Excel VBA Macro on the method PasteSpecial

爱⌒轻易说出口 提交于 2019-12-11 16:17:20
问题 I'm working on a macro to concatenate rows coming from different Excel files all located in the same directory Here is the current version: Sub Compilationb() Dim Temp As String Dim Lignea As Long Temp = Dir(ActiveWorkbook.Path & "\*.xls") Application.DisplayAlerts = False Workbooks("RecapB.xls").Sheets(1).Range("A2:Z60000").ClearContents Do While Temp <> "" If Temp <> "RecapB.xls" Then Workbooks.Open ActiveWorkbook.Path & "\" & Tempa Workbooks(Tempa).Sheets(1).Range("A4").CurrentRegion.Copy

What does the addSubview method look like?

流过昼夜 提交于 2019-12-11 16:10:33
问题 I'm aware of it's function and how to use the addSubview method. What would like to know is what the method looks like, the code used in that method it self.. and if someone could point me to the right direction in finding this out for my self next time. I assume I could find it in the Developer Documentation, and I found the method, and what it does (which I already know) but I'd like to see sample code, if possible. Thanks =] 回答1: The implementation code is not publicly available, iOS is

Why can't I run such scala code? (reduceRight List class method)

社会主义新天地 提交于 2019-12-11 15:58:22
问题 My code: abstract class List[T] { def reduceRight(op: (T, T) => T): Either[String, T] = this match { case Nil => Left("reduce on empty list") case x => Right(x) case x::xs => Right(op(x, xs, reduceRight(op))) } } My error: pattern type is incompatible with expected type, dound: Nil.type, required: List[T] I'm a complete newbie in Scala, so, please, describe your answer. 回答1: tldr: name your class something else, have the method take in a second parameter which is the List you want to reduce.

Why this method's return part is not working

会有一股神秘感。 提交于 2019-12-11 15:29:19
问题 I am trying to write a method which returns a new value. Following code is modified from here: | stripChars | stripChars := [ :string :chars | str := string reject: [ :c | chars includes: c ]. str displayNl. "THIS WORKS." ^ str "THIS DOES NOT WORK." ]. newstr := stripChars value: 'She was a soul stripper. She took my heart!' value: 'aei'. newstr displayNl. Although above function creates new string and displays it, there is error in returning or receiving returned new string: $ gst make_fn