Search Results

Search found 3244 results on 130 pages for 'nil'.

Page 1/130 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Assign to an array and replace emerged nil values

    - by Tobias
    Greetings! When assigning a value to an array as in the following, how could I replace the nils by 0? array = [1,2,3] array[10] = 2 array # => [1, 2, 3, nil, nil, nil, nil, nil, nil, nil, 2] If not possible when assigning, how would I do it the best way afterwards? I thought of array.map { |e| e.nil? ? 0 : e }, but well… Thanks!

    Read the article

  • In Ruby, what is good way to filter all the methods of an object that contain the word "time" in it?

    - by Jian Lin
    I tried the following and it was partly working: >> s.methods.map {|n| n if n =~ /time/} => [nil, nil, nil, nil, nil, nil, nil, nil, "skip_time_zone_conversion_for_attri butes", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ni l, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ni l, "timestamped_migrations", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "time_zone_aware _attributes", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "default_timezone", nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "recor d_timestamps", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil] >> s.methods.each {|n| p n if n =~ /time/} "skip_time_zone_conversion_for_attributes" "timestamped_migrations" "time_zone_aware_attributes" "default_timezone" "record_timestamps" => ["extended_by", "before_create", "vote_ids=", "save_without_dirty", "_delete" , "touch", "daemonize", "after_destroy", "skip_time_zone_conversion_for_attribut es", "methods", "send", "to_query", "becomes", "after_validation", "store_full_s ti_class?", "save_with_transactions!", "autosave_associated_records_for_votes", "require_library_or_gem", "enum_for", "taint", "instance_variable_defined?", "ac [...] and the rest of the whole array >> s.methods.filter {|n| n =~ /time/} NoMethodError: undefined method `filter' for #<Array:0x4de6b00> from (irb):93

    Read the article

  • Change nil's to zeroes in elisp

    - by mageslayer
    Hi all I'd like to ask - what is the function doing nil conversion from nil's to zeroes in elisp? I'm a newbie and I think I am inventing the wheel with my code: (defun chgnull (x) (if (null x) 0 1)) (mapcar 'chgnull '(1 2 nil)) Search through Emacs sources by keyword "to zero" and such haven't shown anything relevant.

    Read the article

  • Sorting by dates (including nil) with NSFetchedResultsController

    - by glorifiedHacker
    In my NSFetchedResultsController, I set a sortDescriptor that sorts based on the date property of my managed objects. The problem that I have encountered (along with several others according to Google) is that nil values are sorted at the earliest end rather than the latest end of the date spectrum. I want my list to be sorted earliest, earlier, now, later, latest, nil. As I understand it, this sorting is done at the database level in SQLite and so I cannot construct my own compare: method to provide the sorting I want. I don't want to manually sort in memory, because I would have to give up all of the benefits of NSFetchedResultsController. I can't do compound sorting because the sectionNameKeyPaths are tightly coupled to the date ranges. I could write a routine that redirects indexPath requests so that section 0 in the results controller gets mapped to the last section of the tableView, but I fear that would add a lot of overhead, severely increase the complexity of my code, and be very, very error-prone. The latest idea that I am considering is to map all nil dates to the furthest future date that NSDate supports. My left brain hates this idea, as it feels more like a hack. It will also take a bit of work to implement, since checking for nil factors heavily into how I process dates in my app. I don't want to go this route without first checking for better options. Can anyone think of a better way to get around this problem?

    Read the article

  • Getting ActiveRecord (Rails) to_xml to use xsi:nil and xsi:type instead of nil and type

    - by nbeyer
    The default behavior of XML serialization (to_xml) for ActiveRecord objects will emit 'type' and 'nil' attributes that are similar to XML Schema Instance attributes, but aren't set in a XML Namespace. For example, a model might produce an output like this: <user> <username nil="true" /> <first-name type="string">Name</first-name> </user> Is there anyway to get to_xml to utilize the XML Schema Instance namespace and prefix the attributes and the values? Using the above example, I'd like to produce the following: <user xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xs="http://www.w3.org/1999/XMLSchema"> <username xsi:nil="true" /> <first-name xsi:type="xs:string">Name</first-name> </user>

    Read the article

  • Inserting nil Values into Sqlite Database?

    - by Chris
    I am working on an iPhone App where I am pulling data from an XML file and inserting it into a sqlite database located in the App. I am able to successfully do this process, but it appears that if I try to sqlite3_bind_text with a NSString that has a value of "nil", the App quickly dies. This is an example of code that fails: (modified for this example) // idvar = 1 // valuevar = nil const char *sqlStatement = "insert into mytable (id, value) VALUES(?, ?)"; sqlite3_stmt *compiledStatement = nil; sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL); sqlite3_bind_int(compiledStatement, 1, [idvar intValue]);; sqlite3_bind_text(compiledStatement, 2, [valuevar UTF8String], -1, SQLITE_TRANSIENT);

    Read the article

  • Ruby on rails session = nil

    - by Mathieu
    Hi, In a controller I have 2 actions def action1 session[:test]="test" render :text => session[:test] # output test end def action2 render :text => session[:test] # output nil end I perform first action1 so the session is set Then I perform action2 but session[:test] is nil So what am I doing wrong?

    Read the article

  • NSInvalidArgumentException: *** -[NSPlaceholderString initWithFormat:locale:arguments:]: nil argumen

    - by BU
    I have no idea where in my code is causing this problem. Can someone please take a look and let me know what I am missing? The code is relatively straightforward. +(void)processGetGameOffersByGameWithReply:(NSDictionary *)responseDictionary { GameOffer *gameOffer; @try { SharedResources *s = [SharedResources instance]; GameOffersByGameTableViewController *gameOffersByGameTableViewController = [s gameOffersByGameTableViewController]; NSMutableArray *gameOffersArray = [gameOffersByGameTableViewController gameOffersAsArray]; NSString *dealsCountString = [[responseDictionary valueForKey:@"number_of_deals"] retain]; NSNumber *dealsCount = [[SharedResources convertToNumberFromString:dealsCountString] retain]; int i=0; NSString *keyStringForTitle; NSString *title, *description, *keyStringForDescription; for(int i=0; i < dealsCount; i++) { /*NSString *keyStringForDealID = [NSString stringWithFormat:@"DealID%d", i]; NSString *DealIDString = [responseDictionary valueForKey:keyStringForDealID]; NSNumber *DealID = [[SharedResources convertToNumberFromString:DealIDString] retain];*/ keyStringForTitle = [[NSString alloc] initWithFormat:@"Title%d",i] ; title = [[NSString alloc] initWithFormat:[responseDictionary valueForKey:keyStringForTitle]]; //[[responseDictionary valueForKey:keyStringForTitle] retain]; keyStringForDescription = [[NSString alloc] initWithFormat:@"Description%d", i]; description = [[NSString alloc] initWithFormat:[responseDictionary valueForKey:keyStringForDescription]]; /*NSString *keyStringForGameID = [NSString stringWithFormat:@"GameID%d", i]; NSString *GameIDString = [responseDictionary valueForKey:keyStringForGameID]; NSNumber *GameID = [[SharedResources convertToNumberFromString:GameIDString] retain];*/ gameOffer = [[GameOffer alloc] initWithTitle:title Description:description Image:nil]; //int i =0; SharedResources *s = [SharedResources instance]; [gameOffersArray addObject:[gameOffer retain]]; int j=0; } NSString *temp = nil; int k = 0; //find the navigation controller UINavigationController *myNavigationController = [[s gamesTableViewController] navigationController]; //push the table view controller to the navigation controller; [myNavigationController pushViewController:gameOffersByGameTableViewController animated:YES]; } @catch (NSException *ex) { NSLog(@"Count is %d", [[[[SharedResources instance] gameOffersByGameTableViewController] gameOffersAsArray] count]); NSLog(@"\n%@\n%@", [gameOffer Title], [gameOffer Description] ); [SharedResources LogException:ex]; } } The problem is whenever the program gets done with the for loop, it doesn't execute the "NSString *temp=nil" anymore, it jumps to the catch statement. I tried removing the for loop setting i = 0. The problem doesn't occur anymore. It reaches teh end of the method by adding only one object in the array. The problem only occurs if there's a for loop. In the catch statement, even with the error, I can see that the array is filled properly and the [gameOffer Title] and [gameOffer Description] have the correct values. Thanks so much for your help.

    Read the article

  • Obtaining ActiveRecords if NOT nil

    - by user275729
    I would like to be able to gather all records in a table where the user_id is not null. This is what I have but it doesn't seem to be working (even though I've had it working in a seperate project): named_scope :all_registered, :conditions => ["user_id != ?", nil]

    Read the article

  • No Method Error Undefined method 'save' for nil:NilClass

    - by BennyB
    I'm getting this error when i try to create a "Lecture" via my Lecture controller's create method. This used to work but i went on to work on other parts of the app & then of course i come back & something is now throwing this error when a user tries to create a Lecture in my app. I'm sure its something small i'm just overlooking (been at it a while & probably need to take a break)...but I'd appreciate if someone could let me know why this is happening...let me know if i need to post anything else...thx! The error I get NoMethodError in LecturesController#create undefined method `save' for nil:NilClass Rails.root: /Users/name/Sites/rails_projects/app_name Application Trace | Framework Trace | Full Trace app/controllers/lectures_controller.rb:13:in `create' My view to create a new Lecture views/lectures/new.html.erb <% provide(:title, 'Start a Lecture') %> <div class="container"> <div class="content-wrapper"> <h1>Create a Lecture</h1> <div class="row"> <div class="span 6 offset3"> <%= form_for(@lecture) do |f| %> <%= render 'shared/error_messages', :object => f.object %> <div class="field"> <%= f.text_field :title, :placeholder => "What will this Lecture be named?" %> <%= f.text_area :content, :placeholder => "Describe this Lecture & what will be learned..." %> </div> <%= f.submit "Create this Lecture", :class => "btn btn-large btn-primary" %> <% end %> </div> </div> </div> </div> Then my controller where its saying the error is coming from controllers/lectures_controller.rb class LecturesController < ApplicationController before_filter :signed_in_user, :only => [:create, :destroy] before_filter :correct_user, :only => :destroy def index end def new @lecture = current_user.lectures.build if signed_in? end def create if @lecture.save flash[:success] = "Lecture created!" redirect_to @lecture else @activity_items = [ ] render 'new' end end def show @lecture = Lecture.find(params[:id]) end def destroy @lecture.destroy redirect_to root_path end private def correct_user @lecture = current_user.lectures.find_by_id(params[:id]) redirect_to root_path if @lecture.nil? end

    Read the article

  • iPhone - Cannont access to an IBOutlet (nil valued)

    - by Oliver
    Hello, I have a problem acessing a IBOutlet. I have a NIB inside which there is a tableview, a toolbar and an UILabel (encasulated into a view). The controller (that is the file's owner) is defined as : @interface ChoixPeriodeController : UIViewController <UITableViewDelegate> { IBOutlet UILabel* __periodeInitialeLabel; } @property(nonatomic, retain) UILabel* periodeInitialeLabel; - (void) setSelectedPeriode:(Tache_TypePeriode)typePeriode; In the .m file, this function is called by the parent window to init the Label : - (void) setSelectedPeriode:(Tache_TypePeriode)typePeriode { NSMutableString* tmpString = [NSMutableString string]; [tmpString appendFormat:bla bla bla;....]; self.periodeInitialeLabel.text = tmpString; } Into this function, I can see that self.periodeInitialeLabel is at nil. I can't see why ? Everything is connected into IB... Do you see what can be the problem ?

    Read the article

  • Why does my table values return nil when i clearly initialized them?

    - by user3717078
    players = {} function newPlayer(name) players[name]={x = 200, y = 100} --assign each player their x and y coordinates, which is x: 200 and y: 100 end function checkPosition(name?) -- Do i need a parameter? if players[name].x == 200 and players[name].y == 100 then --says players[name].x is a nil value print("good") else print("bad") end end Error: attempt to index ? (a nil value) Current Situation: The code above says players[name].x is a nil value, I would like to know why since i thought i assigned it in the function newPlayer.

    Read the article

  • Objective C style nil in java?

    - by Usman Ismail
    Objective C has a concept of a nil object which would accept any method call with any parameters without complaining and silently return another nil. I have used something similar in Java using easymock and mockito for testing. Is there something similar for main line code? Is it even a good idea to have something like this? One use-case where I am considering using it is with optional metrics. We have codahale metrics counters on which we call mark() every time an event is generated. This is surrounded by an If/then to check for metrics enabled flag. I could just use a nil object as counter and silently accept the mark call if metrics are not enabled.

    Read the article

  • Ubuntu 12.04 can't detect internal mobile broadband (Gobi 2000)

    - by Anega
    Hi I have been trying Ubuntu to detect and connect using the buit in mobile broadband capability in my HP 110 netbook but until now nothing seems to work Output of lspci command: 00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev e2) 00:1f.0 ISA bridge: Intel Corporation 82801GBM (ICH7-M) LPC Interface Bridge (rev 02) 00:1f.2 SATA controller: Intel Corporation 82801GBM/GHM (ICH7-M Family) SATA Controller [AHCI mode] (rev 02) 01:00.0 Network controller: Broadcom Corporation BCM4312 802.11b/g LP-PHY (rev 01) 02:00.0 Ethernet controller: Atheros Communications Inc. AR8132 Fast Ethernet (rev c0) Output of lsusb command: Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 002: ID 1fea:0008 Bus 005 Device 002: ID 03f0:2a1d Hewlett-Packard Bus 001 Device 005: ID 03f0:241d Hewlett-Packard Gobi 2000 Wireless Modem (QDL mode) So far I have been trying what is intended on several pages, trying to update firmware using wine and then moving .mda or whatever files the update package GobiInstaller.mdi throws out. The results are always the same: After running Output of wine msiexec /a GobiInstaller.msi /qb TARGETDIR="c:\temp" fixme:advapi:GetCurrentHwProfileA (0x33fba8) semi-stub fixme:heap:HeapSetInformation (nil) 1 (nil) 0 fixme:win:RegisterDeviceNotificationA (hwnd=0x13e250, filter=0xf7e984,flags=0x00000001) returns a fake device notification handle! fixme:heap:HeapSetInformation (nil) 1 (nil) 0 fixme:heap:HeapSetInformation (nil) 1 (nil) 0 fixme:advapi:RegisterEventSourceW ((null),L"Bonjour Service"): stub fixme:advapi:ReportEventA (0xcafe4242,0x0004,0x0000,0x00000064, (nil),0x0001,0x00000000,0x79e58c,(nil)): stub fixme:advapi:ReportEventW (0xcafe4242,0x0004,0x0000,0x00000064, (nil),0x0001,0x00000000,0x12e6d0,(nil)): stub fixme:winsock:WSAIoctl WS_SIO_UDP_CONNRESET stub fixme:winsock:WSAIoctl -> SIO_ADDRESS_LIST_CHANGE request: stub fixme:iphlpapi:DeleteIpForwardEntry (pRoute 0x79e920): stub fixme:iphlpapi:CreateIpForwardEntry (pRoute 0x79e958): stub fixme:advapi:ReportEventA (0xcafe4242,0x0004,0x0000,0x00000064, (nil),0x0001,0x00000000,0x79e58c,(nil)): stub fixme:advapi:ReportEventW (0xcafe4242,0x0004,0x0000,0x00000064, (nil),0x0001,0x00000000,0x12e6d0,(nil)): stub fixme:service:EnumServicesStatusW resume handle not supported fixme:service:EnumServicesStatusW resume handle not supported fixme:advapi:ReportEventA (0xcafe4242,0x0004,0x0000,0x00000064,(nil),0x0001,0x00000000,0x79e58c,(nil)): stub fixme:advapi:ReportEventW (0xcafe4242,0x0004,0x0000,0x00000064, (nil),0x0001,0x00000000,0x12e6d0,(nil)): stub fixme:netapi32:NetGetJoinInformation Semi-stub (null) 0x79e644 0x79e63c fixme:winsock:WSAIoctl WS_SIO_UDP_CONNRESET stub fixme:storage:create_storagefile Storage share mode not implemented. err:msi:ITERATE_Actions Execution halted, action L"_693CD41C_A4A2_4FA1_8888_FC56C9E6E13B" returned 1603 err:rpc:I_RpcGetBuffer no binding err:rpc:I_RpcGetBuffer no binding andres@andres-HP-Mini-110-1100:~/.wine/drive_c/Qualcomm$ fixme:advapi:ReportEventA (0xcafe4242,0x0004,0x0000,0x00000064,(nil),0x0001,0x00000000,0x79e588,(nil)): stub fixme:advapi:ReportEventW (0xcafe4242,0x0004,0x0000,0x00000064, (nil),0x0001,0x00000000,0x12e6d0,(nil)): stub And creates 2 empty folders, I have been trying hard and I am not sure if I am doing it the way it should be. Thanks

    Read the article

  • undefined method `build_users' with nested models

    - by Cédric
    I've got into trouble with nested attributes. Here is my Account model : class Account < ActiveRecord::Base has_many :products has_many :blogs has_many :openings has_many :users has_one :logo, :class_name => "AccountPicture" has_one :address, :class_name => "AccountAddress" has_and_belongs_to_many :options accepts_nested_attributes_for :logo, :allow_destroy => true accepts_nested_attributes_for :address, :allow_destroy => true accepts_nested_attributes_for :users, :allow_destroy => true end And here is my User model : class User < ActiveRecord::Base belongs_to :account end As you can see, Account accepts nested attributes for logo, address, and users. While testing, i can use nested attributes for logo and address, but not for user. a = Account.new => #<Account id: nil, hostname: nil, subdomain: nil, name: nil, description: nil, base_line: nil, footer: nil, phone_number: nil, mobile_number: nil, email_address: nil, created_at: nil, updated_at: nil> # building the address works fine >> a.build_address => #<AccountAddress id: nil, account_id: nil, country: nil, state: nil, county: nil, city: nil, suburb: nil, zipcode: nil, street: nil, streetno: nil, longitude: nil, latitude: nil, error_code: nil> # building the users fails >> a.build_users NoMethodError: undefined method `build_users' for #<Account:0x7f6862a5f948> from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:260:in `method_missing' from (irb):2 Thus, in my views, when i use the nested forms, i got this error back : User(#69850615730460) expected, got Array(#69850664775200) Any help would be appreciated. Thanks.

    Read the article

  • Memory management, and async operations: when does an object become nil?

    - by Kenny Winker
    I have a view that will be displaying downloaded images and text. I'd like to handle all the downloading asynchronously using ASIHTTPRequest, but I'm not sure how to go about notifying the view when downloads are finished... If I pass my view controller as the delegate of the ASIHTTPRequest, and then my view is destroyed (user navigates away) will it fail gracefully when it tries to message my view controller because the delegate is now nil? i.e. if i do this: UIViewController *myvc = [[UIViewController alloc] init]; request.delegate = myvc; [myvc release]; Do myvc, and request.delegate now == a pointer to nil? This is the problem with being self-taught... I'm kinda fuzzy on some basic concepts. Other ideas of how to handle this are welcome.

    Read the article

  • runtime error: invalid memory address or nil pointer dereference

    - by Klink
    I want to learn OpenGL 3.0 with golang. But when i try to compile some code, i get many errors. package main import ( "os" //"errors" "fmt" //gl "github.com/chsc/gogl/gl33" //"github.com/jteeuwen/glfw" "github.com/go-gl/gl" "github.com/go-gl/glfw" "runtime" "time" ) var ( width int = 640 height int = 480 ) var ( points = []float32{0.0, 0.8, -0.8, -0.8, 0.8, -0.8} ) func initScene() { gl.Init() gl.ClearColor(0.0, 0.5, 1.0, 1.0) gl.Enable(gl.CULL_FACE) gl.Viewport(0, 0, 800, 600) } func glfwInitWindowContext() { if err := glfw.Init(); err != nil { fmt.Fprintf(os.Stderr, "glfw_Init: %s\n", err) glfw.Terminate() } glfw.OpenWindowHint(glfw.FsaaSamples, 1) glfw.OpenWindowHint(glfw.WindowNoResize, 1) if err := glfw.OpenWindow(width, height, 0, 0, 0, 0, 32, 0, glfw.Windowed); err != nil { fmt.Fprintf(os.Stderr, "glfw_Window: %s\n", err) glfw.CloseWindow() } glfw.SetSwapInterval(1) glfw.SetWindowTitle("Title") } func drawScene() { for glfw.WindowParam(glfw.Opened) == 1 { gl.Clear(gl.COLOR_BUFFER_BIT) vertexShaderSrc := `#version 120 attribute vec2 coord2d; void main(void) { gl_Position = vec4(coord2d, 0.0, 1.0); }` vertexShader := gl.CreateShader(gl.VERTEX_SHADER) vertexShader.Source(vertexShaderSrc) vertexShader.Compile() fragmentShaderSrc := `#version 120 void main(void) { gl_FragColor[0] = 0.0; gl_FragColor[1] = 0.0; gl_FragColor[2] = 1.0; }` fragmentShader := gl.CreateShader(gl.FRAGMENT_SHADER) fragmentShader.Source(fragmentShaderSrc) fragmentShader.Compile() program := gl.CreateProgram() program.AttachShader(vertexShader) program.AttachShader(fragmentShader) program.Link() attribute_coord2d := program.GetAttribLocation("coord2d") program.Use() //attribute_coord2d.AttribPointer(size, typ, normalized, stride, pointer) attribute_coord2d.EnableArray() attribute_coord2d.AttribPointer(0, 3, false, 0, &(points[0])) //gl.DrawArrays(gl.TRIANGLES, 0, len(points)) gl.DrawArrays(gl.TRIANGLES, 0, 3) glfw.SwapBuffers() inputHandler() time.Sleep(100 * time.Millisecond) } } func inputHandler() { glfw.Enable(glfw.StickyKeys) if glfw.Key(glfw.KeyEsc) == glfw.KeyPress { //gl.DeleteBuffers(2, &uiVBO[0]) glfw.Terminate() } if glfw.Key(glfw.KeyF2) == glfw.KeyPress { glfw.SetWindowTitle("Title2") fmt.Println("Changed to 'Title2'") fmt.Println(len(points)) } if glfw.Key(glfw.KeyF1) == glfw.KeyPress { glfw.SetWindowTitle("Title1") fmt.Println("Changed to 'Title1'") } } func main() { runtime.LockOSThread() glfwInitWindowContext() initScene() drawScene() } And after that: panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x0 pc=0x41bc6f74] goroutine 1 [syscall]: github.com/go-gl/gl._Cfunc_glDrawArrays(0x4, 0x7f8500000003) /tmp/go-build463568685/github.com/go-gl/gl/_obj/_cgo_defun.c:610 +0x2f github.com/go-gl/gl.DrawArrays(0x4, 0x3, 0x0, 0x45bd70) /tmp/go-build463568685/github.com/go-gl/gl/_obj/gl.cgo1.go:1922 +0x33 main.drawScene() /home/klink/Dev/Go/gogl/gopher/exper.go:85 +0x1e6 main.main() /home/klink/Dev/Go/gogl/gopher/exper.go:116 +0x27 goroutine 2 [syscall]: created by runtime.main /build/buildd/golang-1/src/pkg/runtime/proc.c:221 exit status 2

    Read the article

  • Checking for nil in view in Ruby on Rails

    - by seaneshbaugh
    I've been working with Rails for a while now and one thing I find myself constantly doing is checking to see if some attribute or object is nil in my view code before I display it. I'm starting to wonder if this is always the best idea. My rationale so far has been that since my application(s) rely on user input unexpected things can occur. If I've learned one thing from programming in general it's that users inputting things the programmer didn't think of is one of the biggest sources of run-time errors. By checking for nil values I'm hoping to sidestep that and have my views gracefully handle the problem. The thing is though I typically for various reasons have similar nil or invalid value checks in either my model or controller code. I wouldn't call it code duplication in the strictest sense, but it just doesn't seem very DRY. If I've already checked for nil objects in my controller is it okay if my view just assumes the object truly isn't nil? For attributes that can be nil that are displayed it makes sense to me to check every time, but for the objects themselves I'm not sure what is the best practice. Here's a simplified, but typical example of what I'm talking about: controller code def show @item = Item.find_by_id(params[:id]) @folders = Folder.find(:all, :order => 'display_order') if @item == nil or @item.folder == nil redirect_to(root_url) and return end end view code <% if @item != nil %> display the item's attributes here <% if @item.folder != nil %> <%= link_to @item.folder.name, folder_path(@item.folder) %> <% end %> <% else %> Oops! Looks like something went horribly wrong! <% end %> Is this a good idea or is it just silly?

    Read the article

  • Core Data deleteObject: sets attributes to nil

    - by SG1
    I am implementing an undo/redo mechanism in my app. This works fine for lots of cases. However, I can't undo past deleteObject:. the object is correctly saved in the undo queue, and I get it back and reinsterted into the Core Data stack just fine when calling undo. The problem is that all it's attributes are getting set to nil when I delete it. I have an entity "Canvas" with a to-many relationship called "graphics" to a "Graphic" entity, which has its inverse set to "canvas". Deleting a Graphic, then inserting it back, doesn't work. Here's the code (the redo method is basically the same): - (void)deleteGraphic:(id)aGraphic { //NSLog(@"undo drawing"); //Prepare the undo/redo [self.undoManager beginUndoGrouping]; [self.undoManager setActionName:@"Delete Graphic"]; [[self.detailItem valueForKey:@"graphics"] removeObject:aGraphic]; [[self managedObjectContext] deleteObject:aGraphic]; //End undo/redo [self.undoManager registerUndoWithTarget:self selector:@selector(insertGraphic:) object:aGraphic]; [self.undoManager endUndoGrouping]; NSLog(@"graphics are %@", [self sortedGraphics]); //Update drawing [self.quartzView setNeedsDisplay]; } and here's the wierdness: Before delete: graphics are ( <NSManagedObject: 0x1cc3f0> (entity: Graphic; id: 0x1c05f0 <x-coredata:///Graphic/t840FE8AD-F2E7-4214-822F-7994FF93D4754> ; data: { canvas = 0x162b70 <x-coredata://A919979E-75AD-474D-9561-E0E8F3388718/Canvas/p20>; content = <62706c69 73743030 d4010203 04050609 0a582476 65727369 6f6e5424 746f7059 24617263 68697665 7258246f 626a6563 7473>; frameRect = nil; label = nil; order = 1; path = "(...not nil..)"; traits = "(...not nil..)"; type = Path; }) After redo: graphics are ( <NSManagedObject: 0x1cc3f0> (entity: Graphic; id: 0x1c05f0 <x-coredata:///Graphic/t840FE8AD-F2E7-4214-822F-7994FF93D4754> ; data: { canvas = nil; content = nil; frameRect = nil; label = nil; order = 0; path = nil; traits = nil; type = nil; }), You can see it's the same object, just totally bleached by Core Data. The relationship delete rouls apparently have nothing to do with it as I've set them to "No Action" in a test.

    Read the article

  • Lua - Iterate Through Table With nil Values

    - by Tony Trozzo
    My lua function receives a table that is of the array form: { field1, field2, nil, field3, } No keys, only values. I'm trying to convert this to a pseudo CSV form by grabbing all the fields and concatenating them into a string. Here is my function: function ArenaRewind:ConvertToCSV(tableName) csvRecord = "\n" for i,v in pairs(tableName) do if v == nil then v = "nil" end csvRecord = csvRecord .. "\"" .. v .. "\"" if i ~= #tableName then csvRecord = csvRecord .. "," end end return csvRecord end Not the prettiest code by any means, but it seems to iterate through them and grab all the non-nil values. The other table iteration function is ipairs() which stops as soon as it hits a nil value. Is there any easy way to grab all of these fields including the nil values? The tables are various sizes, so I hope to refrain from accessing each part like an array [i.e., tableName[1] through tableName[4]) and just grabbing the nil values that way. Thanks in advance.

    Read the article

  • iphone - mutableArray cannot store nil objects

    - by Mike
    I have a mutable array that is retained and storing several objects. At some point, one object may become nil. When this happens the app will crash, because arrays cannot have nil objects. Imagine something like [object1, object2, object3, nil]; then, object2 = nil [object1, nil, object3, nil]; that is not possible because nil is the end of array marker. So, how can I solve that? thanks for any help.

    Read the article

  • ActionMailer sent with body unavailable in view

    - by yelvert
    So ive got a ActionMailer mailer class ReportMailer < ActionMailer::Base def notify_doctor_of_updated_document(document) recipients document.user.email_id from "(removed for privacy)" subject "Document #{document.document_number} has been updated and saved as #{document.status}" sent_on Time.now body :document => document end end and the view is Document <%= @document.class %> but when running >> d = Document.last => #<Document id: "fff52d70-7ba2-11de-9b70-001ec9e252ed", document_number: "ABCD1234", procedures_count: 0, user_id: "630", created_at: "2009-07-28 18:18:07", updated_at: "2009-08-30 20:59:41", active: false, facility_id: 94157, status: "incomplete", staff_id: nil, transcriptionist_id: nil, job_length: nil, work_type: nil, transcription_date: nil, non_trans_edit_date: nil, pervasync_flag: true, old_id: nil> >> ReportMailer.deliver_notify_doctor_of_updated_document(d) => #<TMail::Mail port=#<TMail::StringPort:id=0x8185326c> bodyport=#<TMail::StringPort:id=0x8184d6b4>> from the console this is printed in the log Sent mail to (removed for privacy) Date: Tue, 11 May 2010 20:45:14 -0500 From: (removed for privacy) To: (removed for privacy) Subject: Document ABCD1234 has been updated and saved as incomplete Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=mimepart_4bea082ab4ae8_aa4800b81ac13f5 --mimepart_4bea082ab4ae8_aa4800b81ac13f5 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: Quoted-printable Content-Disposition: inline Document NilClass= --mimepart_4bea082ab4ae8_aa4800b81ac13f5--

    Read the article

  • Does NULL and nil are equal?

    - by monish
    Hi Guys, Actually my question here is does Null and nil are equal or not? I had an Example but I am confused when they are equal when they are not. NSNull *nullValue = [NSNull null]; NSArray *arrayWithNull = [NSArray arrayWithObject:nullValue]; NSLog(@"arrayWithNull: %@", arrayWithNull); id aValue = [arrayWithNull objectAtIndex:0]; if (aValue == nil) { NSLog(@"equals nil"); } else if (aValue == [NSNull null]) { NSLog(@"equals NSNull instance"); if ([aValue isEqual:nil]) { NSLog(@"isEqual:nil"); } } Here in the above case it shows that both Null and nil are not equal and it displays "equals NSNull instance" NSString *str=NULL; id str1=nil; if(str1 == str) { printf("\n IS EQUAL........"); } else { printf("\n NOT EQUAL........"); } And in the second case it shows both are equal and it displays "IS EQUAL". Anyone's help will be much appreciated. Thank you, Monish.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >