global-variables

Make a global array for each user in ruby

和自甴很熟 提交于 2019-12-13 04:58:17
问题 I have an issue and I'm trying to figure out the best/simplest way to resolve this... I have multiple users on my app. the app allows users to add books to a read-queue list (like a list of books a user can keep tabs on). Originally, I set the read-queue list as a global array. However this meant that multiple users were adding books to a single global array. If user1 added 3 books, user2 would also see those 3 books. Or if user1 cleared the read-queue list, user2's books were cleared too.

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 := ...

Creating a global object across classes

眉间皱痕 提交于 2019-12-13 03:59:42
问题 I need to create a global object that will work and can be used across all the classes in the program. I've done some research and seen the solution seems to be implementing it in the AppDelegate, but there doesn't seem to be much explanation as to how to accomplish this and more importantly this doesn't really seem correct as per my understand of the AppDelegate purpose. 回答1: you should check the singleton pattern: In software engineering, the singleton pattern is a design pattern that

Don't understand global variables

百般思念 提交于 2019-12-13 03:55:22
问题 I'm developing an app for iPad that often needs to share variables. Too me it seems like the easiest solution would be to create a class with global variables instead of focusing on passing back and forth - as I've also had some problems with that. What's the easiest way to create and use global variables in objective-C for iPad IOS7 using Xcode 5 with storyboards? (I know there are duplicates but I can't make it work) 回答1: Edit: following @nhgrif and others comments, I am slightly changing

How do I get the value of a Simulink struct from the workspace within a MATLAB function?

故事扮演 提交于 2019-12-13 03:51:54
问题 I need to access the values of variables in MATLAB's workspace of type Simulink.parameter : CAL_vars = dsdd('find','/path/CAL','ObjectKind','Variable','Property',{'name' 'Class' 'value' 'CAL'}) %gets ids of variables in data dictionary i = 10 for i=1:length(CAL_vars) var_name = dsdd('GetAttribute',CAL_vars(i),'name'); % gets names of variables in data dict var_eval = eval(var_name); % this works in standalone script and it does exactly % what I need, but once i put it in the function I need

Why do Global Variables exist in Ruby? [closed]

僤鯓⒐⒋嵵緔 提交于 2019-12-13 03:28:34
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . I've read C2Wiki on Global Variables, and I have three questions about them (at the bottom of this post). The main question is: If Global Variables are so bad, why does Ruby have them? Also, I've noticed some interesting behaviour regarding Global Variables in Ruby, that

PHP access external $var from within a class function

我是研究僧i 提交于 2019-12-13 03:25:18
问题 In PHP, how do you use an external $var for use within a function in a class? For example, say $some_external_var sets to true and you have something like class myclass { bla .... bla .... function myfunction() { if (isset($some_external_var)) do something ... } } $some_external_var =true; $obj = new myclass(); $obj->myfunction(); Thanks 回答1: Global $some_external_var; function myfunction() { Global $some_external_var; if (!empty($some_external_var)) do something ... } } But because Global

Concurrent XMLRPC-C calls with global ServerProxy object not working as expected

老子叫甜甜 提交于 2019-12-13 02:36:24
问题 I am encountering a strange behaviour while sending XMLRPC requests to a server (XMLRPC-C). I intend to send several requests simultaneously with a pool of processes, as shown below. Each time I make a request I create a new ServerProxy object. I know that this leads to poor performance, instead I should be creating only one object for each process and then reusing those objects for subsequent calls. But the issue I am having is more clearly visible (and easily explained) this way. The

ExceptionInInitializerError

巧了我就是萌 提交于 2019-12-13 01:56:16
问题 I'm trying to initialize GL11 because i was having troubling referencing a method that had GL11 gl as its argument. I tried to initialize it in my renderer class but it didn't work so I figured that it the initialization was messing with the renderer and created a new class to initialize in. import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLContext; import javax.microedition.khronos.egl.EGLDisplay; import

Create and use multiple variables in a loop in Python

a 夏天 提交于 2019-12-13 01:34:10
问题 I'm trying to write a loop in Python that creates variables and also uses created an not-yet-created variables to produce a system of linear equations. This is what I've got so far: P=[[0, 0, 0, 0.5, 0, 0.5], [0.1, 0.1, 0, 0.4, 0, 0.4], [0, 0.2, 0.2, 0.3, 0, 0.3], [0, 0, 0.3, 0.5, 0, 0.2], [0, 0, 0, 0.4, 0.6, 0], [0, 0, 0, 0, 0.4, 0.6]] for j in range(6): globals()['x%s' % j] = 0 for i in range(6): globals()['x%s' % j] += P[i][j]*globals()['x%s' % i] but I get a KeyError output because of the