scope

Javascript self executing functions and variable scope

别来无恙 提交于 2019-12-13 05:12:32
问题 Could someone explain to me this behavior? var obj = function() { var _bar = 10; function i_bar(){return ++_bar;} return { bar : _bar, i_bar: i_bar } }(); obj.bar // prints 10, OK obj.i_bar() // prints 11, OK obj.bar = 0 // prints 0, OK obj.i_bar() // prints 12, NOK Since the only variable is _bar , shouldn't the last obj.i_bar() have printed 1 instead of 12 ? 回答1: Your bar is not the same references as what i_bar is referencing. Value types are not by reference, so you are copying bar into

MDX - rewrite a query using scope

喜夏-厌秋 提交于 2019-12-13 04:58:31
问题 I have an MDX query IIF ( IsLeaf([PnL].[PnL_A].CurrentMember) , [Measures].[PnL - Plan] * [PnL].[Flag 5].CurrentMember.MemberValue ,Sum ( [PnL].[PnL_A].CurrentMember.Children ,[Measures].[PnL- Plan (signed)] ) ) What it does: The whole thing represents profit and loss. Unfortunately, it is constructed in a way that there are two columns: value of a profit or loss, and flag in the other column. So if the flag ( [PnL].[Flag 5] ) is set to -1 , the value ( [Measures].[PnL - Plan] ) is a loss, if

How to Show True/False Boolean In Separate Tables on the Same Index Page?

ε祈祈猫儿з 提交于 2019-12-13 04:49:48
问题 I'm able to check off the Boolean in the _form, but then the "goal" only shows in the "accomplished" goals table and not in the goals table above it (regardless of if it is checked off or not). How can I show false goals (those goals not checked off as completed) in the top table and true goals (those checked off as completed) in the bottom table? Sorry for the code bomb drop, I'm new to Boolean & scopes so I wanted to make sure I showed all the code that might be useful to solving this

Variable scope in a jQuery plugin?

梦想的初衷 提交于 2019-12-13 04:43:04
问题 I continue a question, what I previously asked. It was a too simple sample :) There is a plugin, what's syntax often used nowadays. I want to create an element at the initialization, and I want access to it from another methods. In the example below, I put it's declaration pretty deeply, but if I put it outside the init method, the open method drop an error, because it can't find it. (I'm not sure am I call the methods from another in the right way...) (function($, window, document, undefined

Scope of variable inside do-while loop

大兔子大兔子 提交于 2019-12-13 04:38:08
问题 I'm trying to loop through an entire program if the user inputs "y" or "Y" when they are prompted at the end of the program, but I'm getting a "cannot find symbol - variable response" error since the variable I declared is inside the do-while loop, therefore I suppose I can't use it in the condition of the do-while loop. Is there any way to get around this problem and still be able to loop through the program if the user inputs a "y" or "Y"? This is all in the main method and getFileRunStats

Which objects to make global, which to make local?

℡╲_俬逩灬. 提交于 2019-12-13 04:26:03
问题 To avoid the moderators who don't like general questions, this is a Visio VBA one but I didn't want to include that in the title as it's a bit niche, and I guess the answer might be generic :-) My code has the following variables: Public gappVisio As Visio.Application Public gdocFile As Visio.Document Public gpagDiagram As Visio.Page For those unfamilar with Visio, you create an application object, open the document, then set a reference to a page in the document where you can actually do

Declare Locally or Globally in Delphi?

醉酒当歌 提交于 2019-12-13 04:25:05
问题 I have a procedure my program calls tens of thousands of times that uses a generic structure like this: procedure PrintIndiEntry(JumpID: string); type TPeopleIncluded = record IndiPtr: pointer; Relationship: string; end; var PeopleIncluded: TList<TPeopleIncluded>; PI: TPeopleIncluded; begin { PrintIndiEntry } PeopleIncluded := TList<TPeopleIncluded>.Create; { A loop here that determines a small number (up to 100) people to process } while ... do begin PI.IndiPtr := ...; PI.Relationship := ...

Angular - update scope in Directive

耗尽温柔 提交于 2019-12-13 03:48:10
问题 I'm having problems updating a scope var in a directive, I don't want to have to add HTML in the directive, is it possible to just have the value of the scope var updated. The get-event links will update a variety of text / links / images, but first I just want it to update the scope var name Index.jade div(ng-controller='AppCtrl') h2 Hello {{name}} a(href={{link}}) test a.playlist(get-event rel='1000') 1000 br br a.playlist(get-event rel='2000') 2000 br br a.playlist(get-event rel='3000')

JavaScript IIFE

我的梦境 提交于 2019-12-13 03:43:57
问题 I'll admit I'm pretty green when it comes to JavaScript and it doesn't help that every time I think I'm getting it some weird curve ball throws me right off. I've got a js file something like this: (function (myiife, $) { var myArrayOfThings = []; myiife.myFunction = function (id) { var cachedThing = myiife.getFromArray(id); if (cachedThing === null) { // get from server } else { // do something with cached item } }; myiife.getFromArray = function (idToFind) { for (var i = 0, len =

Variables of tensorflow generate error in a loop

纵然是瞬间 提交于 2019-12-13 03:38:46
问题 I have a similar problem to TensorFlow: varscope.reuse_variables(). I am doing cross-validation on a dataset. Each time I call a function e.g. myFunctionInFile1()) with new data (currently due to limited space, I am omitting the data assigning details). This function is not in same python file. Because of Which I import this function from that file in my main python file (file2). This function creates a complete CNN and train and test a model on the given training and testing data with newly