constants

Swift 2 unused constant warning

丶灬走出姿态 提交于 2020-01-12 23:16:32
问题 I am getting a warning saying my constant is unused: Initialization of immutable value 'myConst' was never used; consider replacing with assignment to '_' or removing it if someVal["value"] != nil { let myConst = someVal["value"] } So what will renaming let myConst = someVal["value"] into _ myConst = someVal["value"] do/mean? 回答1: You're not replacing let with _ , but you're replacing the variable name with it. If the variable isn't used anywhere in the code it's irrelevant so the line can be

Is it possible in android to define constants in XML that vary with configuration

风格不统一 提交于 2020-01-12 06:30:10
问题 I am interested in having an XML layouts in Android change size depending on landscape or portrait viewing (and maybe other configurations later). <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_alignParentBottom="true" android:background="@drawable/stream_bg_1px_wide" android:layout_height="150dip" > In this example I just want to vary the 150dip size depending on landscape or portrait, not change anything else. I am

Python - Best/Cleanest way to define constant lists or dictionarys

人盡茶涼 提交于 2020-01-12 03:59:25
问题 First time user on stack overflow and I'm excited to be here. INTRO: I recently began the magical adventure into the world of Python programming - I love it. Now everything has gone smoothly in my awkward transition from C, but I'm having trouble creating something which would be synonymous to a HEADER file (.h). PROBLEM: I have medium sized dictionaries and lists (about 1,000 elements), lengthy enums, and '#defines' (well not really), but I can't find a CLEAN way to organize them all. In C,

Uninitialized constant error pertaining to Rails' namespaces

南楼画角 提交于 2020-01-06 20:08:09
问题 I posted this question before, but changed some variable names and realized my mistake too late, so this code is unaltered in any way. Error: Routing Error uninitialized constant Firefighters Rails.root: /Users/Vladdy/Dropbox/dev/firestaff Here's the relevant, erroring bit from routes.rb : # get '/firefighters/dashboard' => 'firefighters#dashboard' namespace :firefighters do get '/dashboard' => 'firefighters#dashboard' # Namely, this one. get '/dashboard/:date' => 'firefighters#dashboard' get

When an instance of a class is initialized, what is the sequence?

被刻印的时光 ゝ 提交于 2020-01-06 18:05:15
问题 class Actor { let agent: String? = "nobody" init(agent: String){ self.agent = agent // error: immutable value 'self.agent' may only be initialized once } } let John = Actor(agent: "xyz") I'm confused about the sequence that is happening here (I'm fully aware of the differences between var and let ). But why do I get that error? If I'm using the init method, then doesn't that mean I'm not using the default parameter? Why can't I change the default constant with another one? 回答1: You cannot

When an instance of a class is initialized, what is the sequence?

妖精的绣舞 提交于 2020-01-06 18:03:29
问题 class Actor { let agent: String? = "nobody" init(agent: String){ self.agent = agent // error: immutable value 'self.agent' may only be initialized once } } let John = Actor(agent: "xyz") I'm confused about the sequence that is happening here (I'm fully aware of the differences between var and let ). But why do I get that error? If I'm using the init method, then doesn't that mean I'm not using the default parameter? Why can't I change the default constant with another one? 回答1: You cannot

Overridable Constant?

橙三吉。 提交于 2020-01-06 16:34:37
问题 Maybe I should just make this a public member, but I keep thinking it should be a constant. SCENARIO I have forms I'm rendering into PDFs (using iTextSharp). In code, the forms themselves all inherit a base class ( OrderForm ). Within OrderForm , there are a list of constants that I use for measurements when aligning things for the PDF rendering, such as LEFT_MARGIN , etc. These constants are used in several functions to determine where things go. All the forms are virtually identical as they

const correctness and return values - C++

瘦欲@ 提交于 2020-01-06 15:50:54
问题 Please consider the following code. struct foo { }; template<typename T> class test { public: test() {} const T& value() const { return f; } private: T f; }; int main() { const test<foo*> t; foo* f = t.value(); return 0; } t is a const variable and value() is a constant member-function which returns const T& . AFAIK, a const type is not assignable to a non-const type. But how foo* f = t.value(); compiles well. How this is happening and how can I ensure value() can be only assigned to const

Declaring arrays statically in Constants file

吃可爱长大的小学妹 提交于 2020-01-06 15:17:19
问题 I'm declaring a number of static arrays in a Constants.m file, for example the numberOfRowsInSection count for my tableView: + (NSArray *)configSectionCount { static NSArray *_configSectionCount = nil; @synchronized(_configSectionCount) { if(_configSectionCount == nil) { _configSectionCount = [NSArray arrayWithObjects:[NSNumber numberWithInt:2], [NSNumber numberWithInt:2], [NSNumber numberWithInt:4], [NSNumber numberWithInt:3], [NSNumber numberWithInt:0], nil]; } return _configSectionCount; }

Need to copy the lines just before a particular string using batch file

↘锁芯ラ 提交于 2020-01-06 07:24:29
问题 I have a file like this: Executing resource: D:\waste2\SPC\depks_rtl_teller_custom.spc Executing resource: D:\waste2\SPC\ifpks_msg_incoming_cluster.spc Failed to execute: Executing resource: D:\waste2\SQL\casapks_batch.sql Failed to execute: Executing resource: D:\waste2\SQL\depks_decbatop_kernel.sql Executing resource: D:\waste2\SQL\depks_services.sql Failed to execute: I need a batch file or perl script or ANT script to pick all the lines just in front of the string "Failed to execute:" and