473,408 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

pass hash as function parameter

can i pass a hash as a function parameter. ive seen it been used
before but i can't figure out how to do it.

i would like to call a function like this for example

doSomething({variable1:"blabla",variable2:"blabla" });

how would function doSomething be written for this to work.

I would also like the hash to be optional and the variables in the
hash to be optional.
meaning i should also be able to call doSomething(); with no variables
in it.

Aug 14 '07 #1
3 3349
On Aug 13, 5:09 pm, giloosh <giloos...@gmail.comwrote:
can i pass a hash as a function parameter. ive seen it been used
before but i can't figure out how to do it.

i would like to call a function like this for example

doSomething({variable1:"blabla",variable2:"blabla" });

how would function doSomething be written for this to work.

I would also like the hash to be optional and the variables in the
hash to be optional.
meaning i should also be able to call doSomething(); with no variables
in it.
If by "hash" you mean "object literal" and not "a reproducible method
of turning some kind of data into a (relatively) small number that may
serve as a digital "fingerprint" of the data", then your function just
treats its first argument as an object. What's your question,
exactly? Could you provide more parameters as to what you're trying
to accomplish here?

Aug 14 '07 #2
Lee
giloosh said:
>
can i pass a hash as a function parameter. ive seen it been used
before but i can't figure out how to do it.

i would like to call a function like this for example

doSomething({variable1:"blabla",variable2:"blabla "});

how would function doSomething be written for this to work.

I would also like the hash to be optional and the variables in the
hash to be optional.
meaning i should also be able to call doSomething(); with no variables
in it.
Judging by the fact that you have an example of the calling
syntax but don't know what to do with it, and that you also
don't know how to use the SHIFT key, I'm betting that you're
a particularly slow student and that this is a class assignment.
--

Aug 14 '07 #3
ok forget the word "hash" i dont know why i called it that. for some
reason i thought you call something like this a hash:
{name:"mike",age:"12",gender:"male"}

it's stores data like an array, with key names and values. name would
be the key name and "mike" would be the value.
what do you call it? JSON? i just thought JSON was a pretty new term,
and there was a name for it before JSON.

what ever its called... how would i pass something like that as a
function parameter.
how would the function have to be written?

On Aug 13, 9:22 pm, Lee <REM0VElbspamt...@cox.netwrote:
giloosh said:
can i pass a hash as a function parameter. ive seen it been used
before but i can't figure out how to do it.
i would like to call a function like this for example
doSomething({variable1:"blabla",variable2:"blabla" });
how would function doSomething be written for this to work.
I would also like the hash to be optional and the variables in the
hash to be optional.
meaning i should also be able to call doSomething(); with no variables
in it.

Judging by the fact that you have an example of the calling
syntax but don't know what to do with it, and that you also
don't know how to use the SHIFT key, I'm betting that you're
a particularly slow student and that this is a class assignment.

--

Aug 14 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
by: pembed2003 | last post by:
Hi All, Does C++/STL have hashtable where I can do stuff like: Hashtable h<int>; h.store("one",1); h.store("two",2); and then later retrieve them like:
2
by: Yarik | last post by:
Hello there! I am working with MS SQL Server 2000. I have a table function that takes an integer parameter and returns a table, and I can successfully use it like this (passing a literal as a...
1
by: T.S.Negi | last post by:
Dear Techies, I making one stored procedure, which does some operation based on an interface hash (#) table ---- name #mydata. This stored has two section of code (seperated by parameter value...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
4
by: deko | last post by:
This is a basic program flow question. I'm trying to refractor an AC2000 app and split sections of code into separate modules. But there are a number of collections I create in one big module -...
0
by: Zlatko Matić | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems...
9
by: Alan Silver | last post by:
Hello, I'm a bit surprised at the amount of boilerplate code required to do standard data access in .NET and was looking for a way to improve matters. In Classic ASP, I used to have a common...
4
by: _Mario.lat | last post by:
Hallo, I have a little question: In the function session_set_save_handler I can pass the name of function which deal with session. In Xoops code I see the use of this function like that: ...
1
by: TheCite | last post by:
I am trying to make a function to hash passwords with. Here is the code: Option Compare Database Option Explicit 'function declarations Private Declare Function CryptAcquireContext Lib...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.