scope

Actionscript 3.0: Scope

北慕城南 提交于 2019-12-19 17:44:57
问题 Tutorials usually don't deal with scope in Actionscript. Can you point me to some documentation and/or explain what should I know about it. I want to avoid problems arising from certain classes are not visible at certain places. 回答1: These should help. Function scope: http://livedocs.adobe.com/flex/3/html/help.html?content=03_Language_and_Syntax_21.html Packaging and namespace: http://livedocs.adobe.com/flex/3/html/03_Language_and_Syntax_04.html#119303 回答2: You're a bit vague, but hopefully I

what happened when using the same variable in two layer loops in python?

好久不见. 提交于 2019-12-19 17:38:05
问题 I test the following code: for i in range(3): for i in range(3,5): print "inner i: %d"%(i) print "outer i: %d"%(i) and the output is: inner i: 3 inner i: 4 outer i: 4 inner i: 3 inner i: 4 outer i: 4 inner i: 3 inner i: 4 outer i: 4 I don't understand why in the outer loop the i is 4 but the outer loop still runs for 3 times. It seems that the the variable i in the print "outer i: %d"%(i) line is the i in the inner loop , but when goes to the for i in range(3) it uses the i in the outer loop.

C++ Variable array in a Class Problem

倖福魔咒の 提交于 2019-12-19 12:01:49
问题 I was wondering if there was a way to include a data member which is an array of unfixed size. The function initModulation will create an int array of size M and a Complex array of size M. (Complex is another class and is made up of a real component and imaginary component). The function modulate will need to be able to access these two arrays. These two arrays go out of scope after the init Modulation function is called. To avoid this, I would just make these two data members of the

Delay-bind script block does not work when function is exported from module

只愿长相守 提交于 2019-12-19 11:39:04
问题 I have following function: function PipeScript { param( [Parameter(ValueFromPipeline)] [Object] $InputObject, [Object] $ScriptBlock ) process { $value = Invoke-Command -ScriptBlock $ScriptBlock Write-Host "Script: $value" } } When I define this function directly in script and pipe input into it I get following result which is expected: @{ Name = 'Test' } | PipeScript -ScriptBlock { $_.Name } # Outputs: "Script: Test" But when I define this function inside module and export it with Export

PHP Function Accessing Database Connection

我的未来我决定 提交于 2019-12-19 10:16:48
问题 How do I allow a function to access a database connection without using GLOBAL? config.php DEFINE ('DB_HOSTNAME', 'hostname'); DEFINE ('DB_DATABASE', 'database'); DEFINE ('DB_USERNAME', 'username'); DEFINE ('DB_PASSWORD', 'password'); $dbc = mysqli_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE); if(!$dbc) die("Unable to connect to MySQL: " . mysqli_error($dbc)); functions.php function something() { $info = mysqli_query($dbc, "SELECT info FROM text") or die("Error: ".mysqli_error(

How do I refer to actual 'this' inside CoffeeScript fat-arrow callback?

别来无恙 提交于 2019-12-19 10:08:56
问题 The title says it all. When I use the fat-arrow in CoffeeScript, it stores this first before calling the function. For example: class myClass constructor: -> element = $ "#id" element.click -> @myMethod(@value) return return myMethod: (c)-> window.console.log(c) return would yield var myClass; myClass = (function() { function myClass() { var element; element = $("#id"); element.click(function() { this.myMethod(this.value); }); return; } myClass.prototype.myMethod = function(c) { window

How to access a scope if its name is being used as a query column

╄→尐↘猪︶ㄣ 提交于 2019-12-19 09:49:57
问题 Dealing with some legacy code we came across a rather annoying situation. We are looping through a query with the <cfoutput query="x"> tag. That query has a column named 'url'. Within that loop we need to check if a key exists within the url scope. Since CF puts a priority on what's in the query over general page scopes I can't use a structKeyExists(url,"key") since as far as CF is concerned at this point, url is a string with the value from the current row of the query. How can I break out

Why does declaring an extern variable inside main() works,but not defining it inside main() as well?

北战南征 提交于 2019-12-19 09:24:31
问题 This seems very trivial but a somewhat rigorous explanation for the following behavior will help my understanding of extern a lot.So I'll appreciate your answers. In the following sample program,I've declared an extern variable x inside a function ( main() ).Now if I define the variable at file scope right after main() and assign 8 to it, then the program works fine and 8 is printed.But if I define the variable x inside main() after the printf() ,expecting the extern declaration to link to it

rails - using :select(distinct) with :has_many :through association produces invalid SQL

霸气de小男生 提交于 2019-12-19 08:58:28
问题 User has_many :posts has_many :post_tags, :through => :posts PostTag belong_to :post belongs_to :tag scope :distincttag, :select => ('distinct post_tags.tag_id') with Rails 3.0.4, i get invalid SQL: SELECT post_tags.*, distinct tag_id... at least one other person experienced the same problem: http://www.ruby-forum.com/topic/484938 feature or a bug? thanks 回答1: Does not look like the right thing to put on a scope. Maybe you are trying to accomplish this: class PostTag < ... belong_to :post

scope of local variables of a function in C

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 08:29:27
问题 I have heard about the following scenario right when I started programming in C. " Trying to access from outside, a functions local variable will result in error (or garbage value). Since the stack gets cleared off when we return from the function " But my below code sample prints a value of 50. I am compiling the code with latest GCC compiler. #include <stdio.h> int * left(); int main() { int *p=left(); printf("%d\n",*p); return 0; } int * left() { int i=50; return &i; } Enlight me on this