parameter-passing

Parameter passing with initWithNibName:

这一生的挚爱 提交于 2019-12-08 21:25:04
问题 In iphone Application I need to pass some values to a new viewcontroller object while it create from a method in another viewcontroller class so I can initialize that values in (id)initWithNibName:method of new viewcontroller then I can load those values in viewdidLoad method. what I want to know is how do I pass the values(parameters) to the constructor(initWithNibName) of a new viewcontrollor Object like constructor overloading in java give me some code example just showing how

Rails 4 - Pundit, Scopes: Getting Started

对着背影说爱祢 提交于 2019-12-08 20:15:30
I am really struggling in my efforts over the past 2+ years to try to learn how to use pundit. I am trying to write scoped policies, so that different users can receive objects based on the scope class that they fit into. I have asked several questions on the same topic previously, but I'm not getting any closer to a solution. My recent questions are: here , here , here , here , here and here . There are several others but these give the general picture, that I am struggling with the fundamentals of how to get started. I have a million problems with getting started and realise that after 4

How to best *fake* keyword style function arguments in Rust?

喜你入骨 提交于 2019-12-08 19:36:15
问题 I'm interested to have something functionally similar to keyword arguments in Rust, where they're currently not supported. For languages that provide keyword argument, something like this is common: panel.button(label="Some Button") panel.button(label="Test", align=Center, icon=CIRCLE) I've seen this handled using the builder-pattern, eg: ui::Button::new().label("Some Button").build(panel) ui::Button::new().label("Test").align(Center).icon(CIRCLE).build(panel) Which is fine but at times a

When not to use std::forward with r-values?

北城以北 提交于 2019-12-08 17:20:39
问题 What are the cases when std::forward is not needed? It is used to wrap inner function argument which is templated-rvalue (that is, it can be lvalue or named-rvalue). Like in: template<class T> void outer(T&& t) { inner(std::forward<T>(t)); } I am guessing one case is when inner function parameters are passed by value. Are there other cases? I've got this question when I was writing std::begin(std::forward<Ct>(ct)) where Ct is templated-rvalue-ref. EDIT about possible duplicate If I remember

Passing single value to params argument in NUnit TestCase

痞子三分冷 提交于 2019-12-08 15:58:54
问题 I have the following test: [ExpectedException(typeof(ParametersParseException))] [TestCase("param1")] [TestCase("param1", "param2")] [TestCase("param1", "param2", "param3", "optParam4", "optParam5", "some extra parameter")] public void Parse_InvalidParametersNumber_ThrowsException(params string[] args) { new ParametersParser(args).Parse(); } The first TestCase (obviously) fails with the following error: System.ArgumentException : Object of type 'System.String' cannot be converted to type

Create insert function of any record type in Delphi XE7?

感情迁移 提交于 2019-12-08 13:56:07
问题 I have an record type for each Table in SQL Server. So when I want to insert (or update) a record on table I define a function to do so. Each field in delphi record has equivalent field in SQL table (with exact same name an type). It is too interesting to me to write a function to do this ( for example Inserting) for all record types using Retti. I mean a function that have a parameter for receive any record and creates insert query. I searched a lot and asked this question but finally not

How to pass by reference in Ruby?

妖精的绣舞 提交于 2019-12-08 13:56:05
问题 Currently I'm developing a Watcher class in Ruby, which, among other things, is able to find the period duration of a toggling signal. This is in general rather simple, but a problem I'm facing is that apparently Ruby passes all parameters by value. While researching online I found many different discussions about what "pass by value" and "pass by reference" actually is, but no actual "how to". Coming from a C/C++ background, for me this is an essential part of a programming/scripting

How do I pass a string value from a TextBox between Forms?

断了今生、忘了曾经 提交于 2019-12-08 13:09:03
问题 I have two forms: Form1 which is my app and Form2 which is a login page. I want to pass a value entered into the username textbox (LoginTbox) on Form2 to Form1. This is what I have so far. No error is received, but it seems to be passing nothing. I've tried constructors, but couldn't seem to get that to work either. What am i doing wrong? Program.cs static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form2 fLogin = new Form2(); if

What does map(&:name) mean in Ruby?

此生再无相见时 提交于 2019-12-08 12:21:13
问题 I found this code in a RailsCast: def tag_names @tag_names || tags.map(&:name).join(' ') end What does the (&:name) in map(&:name) mean? 回答1: It's shorthand for tags.map(&:name.to_proc).join(' ') If foo is an object with a to_proc method, then you can pass it to a method as &foo , which will call foo.to_proc and use that as the method's block. The Symbol#to_proc method was originally added by ActiveSupport but has been integrated into Ruby 1.8.7. This is its implementation: class Symbol def

passing a parameter pack over a legacy function signature using forward_as_tuple

寵の児 提交于 2019-12-08 11:42:24
问题 In my app I would like to pass in a parameter pack over a legacy function signature, and change the values. Here is code that illustrates my question with my attempts as comments: #include <tuple> #include <cassert> void LegacySignature( void* param ); template< typename... ArgsT > // using ???; // attempt: can 'template alias' or 'using declaration' make the pack's type visible so I can use it inside the LegacyFunction? void MyFunc( ArgsT&... args ) { auto userArgsTuple = std::forward_as