Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8714491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:36:34+00:00 2026-06-13T05:36:34+00:00

If I declare a map[string]string return value in a function definition, do I have

  • 0

If I declare a map[string]string return value in a function definition, do I have to make it before using it, just like if I had instead declared it in the function body? http://play.golang.org/p/iafZbG2ZbY

package main

import "fmt"

func fill() (a_cool_map map[string]string) {
    // This fixes it: a_cool_map = make(map[string]string)
    a_cool_map["key"] = "value"
    return
}
func main() {
    a_cool_map := fill()
    fmt.Println(a_cool_map)
}

panic: runtime error: assignment to entry in nil map

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:36:34+00:00Added an answer on June 13, 2026 at 5:36 am

    Map types

    The value of an uninitialized map is nil.

    A new, empty map value is made using the built-in function make.

    A nil map is equivalent to an empty map except that no elements may be
    added.

    Yes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code like this: val dm = List[String]() val dk = List[Map[String,Object]]() .....
I have a map declared as follows: map < string , list < string
I have this code, CBString is just a string class I use for some
I have something like this: #include <iostream> #include <map> int main() { std::map<int, int*>
When I try to declare a Dictionary as such: private Dictionary<String, int> map; The
Supposed I have a type I'll call NamedNestedMap std::map<std::string, std::map<std::string, NamedNestedMap> > In this
I have oracle block like DECLARE TYPE emp_array IS VARRAY(100) OF VARCHAR2(30); VAR_PRESENTADDRESS1 varchar2(100);
I have a string property on an entity that I would like to mark
unordered_map<std::string,unordered_map<std::string, std::string> >* storing_vars; I have this variable in the scope declared in the
Declare: LPWSTR** lines= new LPWSTR*[totalLines]; then i set using: lines[totalLines]=&totalText; SetWindowText(totalChat,(LPWSTR)lines[totalLines]); totalLines++; Now I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.